Year Format not changing

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Year Format not changing

Post by gchichester » Fri Nov 25, 2016 3:10 pm

I have set the date format on the PC to Short Date 11/25/16 when I run this code
the Watch shows;
0: BATCHDATE=DRG11252016
0: CYEAR=2016
0: CDAY=25
0: CMONTH=11
0: TODAY=11/25/16
0: BATCHPRE=DRG

[code]GetDate>today
DatePart>today,M,CMonth
DatePart>today,D,CDay
DatePart>today,Y,CYear
Let>BatchDate=%BatchPre%%CMonth%%CDay%%CYear%
msg>BatchDate[/code]

The resulting variable displays the as 2016
What's wrong with my code?
Thank you in advance for all your help
Gil

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Year Format not changing

Post by Marcus Tettmar » Mon Nov 28, 2016 11:38 am

That's what DatePart does. Returns the full year from a date.

If you just want to remove portions of the short date as is then use MidStr:

Code: Select all

MidStr>today,7,2,yearDigits
Or my preference for total portability would be:

Code: Select all

Year>yyyy
MidStr>yyyy,3,2,yy
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Re: Year Format not changing

Post by gchichester » Mon Nov 28, 2016 12:55 pm

Thanks for your response!
When I reviewed the Watch List and saw 0: TODAY=11/25/16, I was expecting the year format to be 16
So If I understand correctly DatePart is not looking at the system Date format for it's results?
Thank you in advance for all your help
Gil

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: Year Format not changing

Post by Marcus Tettmar » Mon Nov 28, 2016 1:00 pm

It wants a valid date format. What a valid date is is somewhat dictated by the system settings. So it DOES look at it, but it is not a substring tool. It still returns a year value. Year values are 4 digits.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

gchichester
Pro Scripter
Posts: 132
Joined: Mon Dec 22, 2008 4:56 pm
Location: St Augustine FL

Re: Year Format not changing

Post by gchichester » Mon Nov 28, 2016 1:05 pm

Thanks for the explanation.
Thank you in advance for all your help
Gil

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