I need to enter today's date in a field.
The format is mm/dd/yy, but since the field on the application is set for mm/dd/yy format, I will only need to enter the actual numbers. For instance, if todays date was 12/24/2005, I would only need to send 122405 to the screen.
The GetDate function returns dates in the mm/dd/yyyy format.
How can I use variables to parse the 12/24/2005 (which is returned from getdate) to get 122405.
Thanks in advance!
Newbie Date Parsing question
Moderators: Dorian (MJT support), JRL
You can easily parse the results of Getdate using Midstr>
Getdate>today
Midstr>today,1,2,mm
Midstr>today,4,2,dd
Midstr>today,9,2,yy
Or:
Instead of GetDate> try the separate functions day>, month> and year>.
Day>dd
Month>mm
Year>yy
//Since Year will no doubt show up as a four digit number we will need to trim it with midstr>.
Midstr>yy,3,2,yy
Hope this helps,
Dick
Getdate>today
Midstr>today,1,2,mm
Midstr>today,4,2,dd
Midstr>today,9,2,yy
Or:
Instead of GetDate> try the separate functions day>, month> and year>.
Day>dd
Month>mm
Year>yy
//Since Year will no doubt show up as a four digit number we will need to trim it with midstr>.
Midstr>yy,3,2,yy
Hope this helps,
Dick
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
...and just to show there's always another way to do anything, the one line conversion using Separate
GetDate>mydate
Separate>mydate,/,part
MessageModal>%mydate% %part_1% %part_2% %part_3%
Actually that MidStr parse isn't very portable, it wouldn't work on the PC I'm using because GetDate returns 9/5/2006.
GetDate>mydate
Separate>mydate,/,part
MessageModal>%mydate% %part_1% %part_2% %part_3%
Actually that MidStr parse isn't very portable, it wouldn't work on the PC I'm using because GetDate returns 9/5/2006.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Always better to use Day, Month and Year because they are unambiguous whereas GetDate is dependent on regional settings.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
That's important information. I would have assumed that day>, month> and Year> were also tied to regional settings. Since all computers within my sphere of influence were set up by me, they all have the same (USA central time windows default) regional setting. Since Getdate> magically provides the same format as month/day/year it never occured to me to check out the differences.
Too bad, I liked the Separate> solution.
Later,
Dick
Too bad, I liked the Separate> solution.
Later,
Dick
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
GetDate returns the date in the format of the short date as set up in regional settings. The help file says "The format of the date depends on the regional settings of the system."
In contrast:
Day - returns the day as a number with a leading zero (01-31).
Month - returns the month as a number with a leading zero (01-12).
Year - returns the year as a four-digit number (0000-9999).
Therefore they are independent of any regional settings.
So I would ALWAYS use Day, Month and Year when formatting dates where you want control of the format.
In contrast:
Day - returns the day as a number with a leading zero (01-31).
Month - returns the month as a number with a leading zero (01-12).
Year - returns the year as a four-digit number (0000-9999).
Therefore they are independent of any regional settings.
So I would ALWAYS use Day, Month and Year when formatting dates where you want control of the format.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?