Recent date format problem

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Recent date format problem

Post by rblack » Tue May 11, 2010 2:01 pm

hello there,

i try to get the recent date and i use the following lines:

Code: Select all

VBSTART
VBEND
Vbeval>DateAdd("d",-3,Date),someday
Vbeval>Year("%someday%"),yearw
Vbeval>Month("%someday%"),monthw
Vbeval>Day("%someday%"),dayw
and i want to input the whole recent date in a form, but it has to be in the file format YYYY-MM-DD , the following line:

Code: Select all

MessageModal>%yearw%-%monthw%-%dayw% 
for today displays: 2010-5-8 , and thats incorrect, i need to have 2010-05-08

in the Macro Sheduller 9 the following lines worked:
//and i cant paste the simple if lines, because the forum engine removes it
//here was a simple IF which added 0 when month or day was less than 10

but
MessageModal>%yearw%-%monthw%-%dayw% still returns the date in the format 2010-5-8 not 2010-05-08

Does anyone know how to solve that riddle?
Last edited by rblack on Tue May 11, 2010 2:08 pm, edited 1 time in total.

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

Post by Marcus Tettmar » Tue May 11, 2010 2:07 pm

You need to pad left with zeros:

VBSTART
VBEND
Vbeval>DateAdd("d",-3,Date),someday
Vbeval>Year("%someday%"),yearw
Vbeval>Right("00" & Month("%someday%"),2),monthw
Vbeval>Right("00" & Day("%someday%"),2),dayw

MessageModal>%yearw%-%monthw%-%dayw%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Post by rblack » Tue May 11, 2010 2:11 pm

it works! didnt know that function! Thank you for super-fast and accurate reply!

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Tue May 11, 2010 2:16 pm

If you don't do the padding Marcus recommends, this form of if statement works. I think you need to disable HTML in your post.

Code: Select all

IF>monthw<10
    Let>monthw=0%monthw%
endif
if>dayw<10
    Let>dayw=0%dayw%
endif

Gale

rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Post by rblack » Thu Jul 08, 2010 10:43 am

gdyvig: i used this solution, and it was workin in the older version of Macro Sheduller, but in the v11 it stopped working. Macrus solution works fine.

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