Date Mgmt - Today minus 1 at month change

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Date Mgmt - Today minus 1 at month change

Post by edauthier » Thu Jul 01, 2010 10:56 am

Hi,
Related to this old post..
http://www.mjtnet.com/forum/viewtopic.php?p=21137#21137

Need to send an application a date in this format:
2010-06-30. So, yyyy-mm-dd. Today, I will need to send 2010-06-30, but the vbscript I am using sends 2010-07-00. Very literally today -1..

The code works perfectly except at the turn of the month.

Here's what I use and assistance is appreciated.

Code: Select all

VBSTART
VBEND
VBEval>Right("0" & DatePart("m", Now()),2) & "/" & Right("0" & DatePart("d", Now())-1,2) & "/" & DatePart("yyyy",Now()),date
separate>date,/,parts
message>%parts_3%-%parts_1%-%parts_2%


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

Post by Marcus Tettmar » Thu Jul 01, 2010 11:04 am

Your code only subtracts one from the day number. It doesn't subtract anything from the current date.

This does what you want:

Code: Select all

VBSTART
VBEND

VBEval>DateAdd("d",-1,date),yesterday
VBEval>Right("0" & DatePart("d","%yesterday%"), 2),day_bit
VBEval>Right("0" & DatePart("m","%yesterday%"), 2),month_bit
VBEval>DatePart("yyyy","%yesterday%"),year_bit

Let>formatted_date=%year_bit%-%month_bit%-%day_bit%

MessageModal>formatted_date
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

edauthier
Pro Scripter
Posts: 84
Joined: Sun Apr 13, 2003 1:26 pm
Location: USA

Post by edauthier » Thu Jul 01, 2010 8:19 pm

I don't care what they say about you Marcus.. YOU'RE THE BEST...!!

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