Community discussions

MikroTik App
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

changing from number to date

Mon Jun 28, 2021 3:37 am

how to change from number to date.
instead of 7 i want to change it to JUL with big letter JUL.
pls help
:log info [:tostr ([:find [:toarray "jan,feb,mar,apr,may,jun,jul,ago,sep,oct,nov,dec"] [:pick $date 0 3]]+2)]
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: changing from number to date  [SOLVED]

Mon Jun 28, 2021 3:54 am

search tag # rextended num2month mon2MON mon2num number month

Can be used various method, but you suggest me some new...

Numerical Month to 3 uppercase month letters:
:global num2month do={ :return [:pick "REXJANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC" ($1*3) (($1*3)+3)] }
:put [$num2month 7]

if on your confusion request you mean how change jul to JUL (suggested from :pick $date 0 3)...

Convert from 3 month letters to 3 uppercase month letters:
:global mon2MON do={ :local strin "janfebmaraprmayjunjulaugsepoctnovdec"; :local strcomp "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"; :return [:pick $strcomp [:find $strin $1 -1] ([:find $strin $1 -1]+3)] }
:put [$mon2MON "jul"]

And this extra..
Convert from MikroTik 3 month letters (from date) to number
:global mon2num do={ :return ([:find "rexjanfebmaraprmayjunjulaugsepoctnovdec" $1 -1] / 3) }
:put [$mon2num "jul"]
Last edited by rextended on Mon Nov 14, 2022 1:18 am, edited 3 times in total.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: changing from number to date

Mon Jun 28, 2021 4:42 am

thanks sir. i forgot to insert the pick date
:local Date [/system clock get date]
:global num2month do={ :return [:pick "REXJANFEBMARAPRMAYJUNJULAGOSEPOCTNOVDEC" [:pick $Date 0 3]+1)] ($1*3) (($1*3)+3)] }
:log info [$num2month]

today is JUN but i need to get the JUL

search tag # rextended num2month Mon2MON Mon2num number month

Can be used various method, but you suggest me some new...

Numerical Month to 3 uppercase month letters:
:global num2month do={ :return [:pick "REXJANFEBMARAPRMAYJUNJULAGOSEPOCTNOVDEC" ($1*3) (($1*3)+3)] }
:put [$num2month 7]

if on your confusion request you mean how change Jul to JUL (suggested from :pick $date 0 3)...

Convert from 3 month letters to 3 uppercase month letters:
:global Mon2MON do={ :local strin "JanFebMarAprMayJunJulAgoSepOctNovDec"; :local strcomp "JANFEBMARAPRMAYJUNJULAGOSEPOCTNOVDEC"; :return [:pick $strcomp [:find $strin $1 -1] ([:find $strin $1 -1]+3)] }
:put [$Mon2MON "Jul"]

And this extra..
Convert from MikroTik 3 month letters (from date) to number
:global Mon2num do={ :return ([:find "RexJanFebMarAprMayJunJulAgoSepOctNovDec" $1 -1] / 3) }
:put [$Mon2num "Jul"]
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: changing from number to date

Mon Jun 28, 2021 9:44 am

(pleae do not quote on useless way, use "Post Reply" button instead, and remove quoted part on your previous message)

the function must not be modified, must be used as example

i made another function and now is like what you need?
:global getMounth do={ :return [:pick [/system clock get date] 0 3] }
:global mon2num do={ :return ([:find "rexjanfebmaraprmayjunjulaugsepoctnovdec" $1 -1] / 3) }
:global num2NEXTmonth do={ :return [:pick "REXFEBMARAPRMAYJUNJULAUGSEPOCTNOVDECJAN" ($1*3) (($1*3)+3)] }
:log info [$num2NEXTmonth [$mon2num [$getMounth]]]
Last edited by rextended on Mon Nov 14, 2022 1:19 am, edited 2 times in total.
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: changing from number to date

Mon Jun 28, 2021 11:37 am

thanks sir it solves my problem.
take care and godbless

Who is online

Users browsing this forum: No registered users and 31 guests