System Independent Date Handling

Hints, tips and tricks for newbies

Moderators: JRL, Dorian (MJT support)

Post Reply
KenHadley
Junior Coder
Posts: 28
Joined: Thu Jul 14, 2011 5:02 pm

System Independent Date Handling

Post by KenHadley » Thu Aug 22, 2013 1:35 pm

I am setting a start and a stop date in variables in a macro:

Code: Select all

Let>StartScrapingAtThisDate=1/1/2012
Let>EndScrapingAtThisDate=1/31/2012
The macro blows up on DatePart on a machine with a Regional setting of 31-Jan-2012 for dates.

I know about DateLocal, but that seems to only supply today's date in the format of the machine is it running on. How can I ensure that my own defined variables are set to a local date format?

Ken

User avatar
JRL
Automation Wizard
Posts: 3529
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Aug 22, 2013 1:45 pm

Its a little more coding but I usually use the Month>, Day>, and Year> functions when I need to know the format of the dates. Their output is independent of the computers regional settings

Code: Select all

Month>mm
Day>dd
Year>CCYY

Let>today=%mm%/%dd%/%CCYY%

MDL>today

KenHadley
Junior Coder
Posts: 28
Joined: Thu Jul 14, 2011 5:02 pm

Post by KenHadley » Thu Aug 22, 2013 8:35 pm

Thank you, JRL. I understand now.

So, I need to do something like:

Code: Select all

Let>dd=31
Let>mm=1
Let>yy=2013

DateLocal>%yy%,%mm%,%dd%,EndScrapingAtThisDate

Then, the variable will have the date in the regional date format.

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

Post by Dorian (MJT support) » Fri Aug 23, 2013 12:19 am

Or just this?

Code: Select all


//Use YYYY,MM,DD
datelocal>2013,12,31,EndScrapingAtThisDate

//See what it looks like
mdl>%EndScrapingAtThisDate%

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