Help with Dates

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
wvfrugalchick
Newbie
Posts: 11
Joined: Sun Jul 23, 2023 4:57 pm

Help with Dates

Post by wvfrugalchick » Sat Jan 04, 2025 9:28 pm

I found this in the help section [snippet=]//get today's date
GetDate>today
//Add 5 days to it
DateAdd>today,D,5,new_date
//get the bits
DatePart>new_date,D,day_part
DatePart>new_date,M,month_part
DatePart>new_date,Y,year_part
//year_part is 4 digits, so we want only last 2
MidStr>year_part,3,2,year_bits
//Make sure we prepend with zeros if day is only 1 char
If>{length("%day_part%") < 2}
Let>day_part=0%day_part%
Endif
//Make sure we prepend with zeros if month is only 1 char
If>{length("%month_part%") < 2}
Let>month_part=0%month_part%
Endif
//now put them together in the format you want (DDMMYY)
Let>formatted_date=%day_part%%month_part%%year_bits%
MessageModal>formatted_date[/snippet]

but, I will admit I have muddled it up over and over again. I'm hoping someone here can help.

I need a script to run every three months.So : 1/1/2025, 4/1/2025, 7/1/2025 and 10/1/2025

Any help in me understand this would be greatly apreaciated

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1397
Joined: Sun Nov 03, 2002 3:19 am

Re: Help with Dates

Post by Dorian (MJT support) » Sat Jan 04, 2025 10:43 pm

Have you considered just using "specific dates/times" at in the scheduler? (Run When). That seems like the simplest option (Added in Version 14.0.2 31/01/2013)

Alternatively, set it to run every day and let the script check the dates and exit if the dates don't match.

Code: Select all

Day>TheDay
Month>TheMonth


if>{(%TheDay%=01) AND ((%TheMonth% = 01) OR (%TheMonth% = 04) OR (%TheMonth% = 07) OR (%TheMonth% = 10))}
//Script goes here
MDL>RUN
ELSE
MDL>Don't run
Exit>0
Endif


wvfrugalchick
Newbie
Posts: 11
Joined: Sun Jul 23, 2023 4:57 pm

Re: Help with Dates

Post by wvfrugalchick » Mon Jan 06, 2025 7:23 pm

thank you! I will give this a try.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts