My needs:
Get today's Date
Subtract 10 days from current date
Parse out 2 digit day, 2 digit month, and 2 digit year
I can use GetDate and Sub to get the date 10 days ago. This causes problem w/ MidStr when I am trying to parse out the pieces since MidStr requires a positional starting point. The starting point will be different on every GetDate call since it will return a 1 digit month sometimes and a 2 digit month sometimes. The same goes for the day.
I can use the Month Day and Year functions to parse out the pieces I need, but then I cannot subtract 10 days from the date because the Date function has no month as a reference.
Is there an easy method of accomplishing what I need without creating horrendous IF statements?
Yet another newbie date question
Moderators: Dorian (MJT support), JRL
This works for me.
Hope it works for you,
Dick
Code: Select all
Month>mm
Day>dd
Year>yyyy
Concat>mm,/%dd%/%yyyy%
sub>mm,10
Midstr>mm,1,2,mon
Midstr>mm,4,2,dy
Midstr>mm,9,2,yr
Dick
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Or:
Also look at VBScript's FormatDateTime function:
http://msdn.microsoft.com/library/en-us ... frame=true
Code: Select all
VBSTART
VBEND
VBEval>Year(Date()-10),yy
VBEval>Month(Date()-10),mm
VBEval>Day(Date()-10),dd
http://msdn.microsoft.com/library/en-us ... frame=true
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?
JRL - problem
I tried something like this originally but it still has a problem.
Lets take today for instance...
your script will make mm = 10/1/2006
when you say MidStr>mm,4,2,dy it = 1/ instead of 01
I guess I will do this but create an IF that says to concatenate a 0 in front of DD if it's less than 10.
Lets take today for instance...
your script will make mm = 10/1/2006
when you say MidStr>mm,4,2,dy it = 1/ instead of 01
I guess I will do this but create an IF that says to concatenate a 0 in front of DD if it's less than 10.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
As stated previously, GetDate returns a date in ShortDate format in accordance with your regional settings. Avoid using it if you want a portable 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?
regional settings
Hey guys,
I just changed the regional settings and used midstr to get what I needed. That seemed to make everything very simple.
Thanks for your help!
I just changed the regional settings and used midstr to get what I needed. That seemed to make everything very simple.
Thanks for your help!