Date calculated wrong

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

Date calculated wrong

Post by timle » Fri Feb 01, 2008 6:29 pm

VBSTART
VBEND


//This to set the new name with ho code
Day>pubday
//Add>pubday,1
Let>pubday=pubday+1
VBEval>Right("0"&"%pubday%",2),pubday
Month>pubmonth
let>EditionCode=ho
let>EditionDate=%pubmonth%%pubday%
let>Product=tvgrid
let>Newname=%EditionCode%%pubmonth%_%pubday%___%EditionCode%%pubmonth%%pubday%%Product%.pdf


On thursday, the file supposed to rename the pubmonth and day to 02_01, It renamed to 01_32

Would someone help me figure out please so it will know the right calendar date
Thank you

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

Post by Marcus Tettmar » Fri Feb 01, 2008 7:08 pm

Let's take a look at that code. We'll assume the date is 31st of Jan. Take a look at this bit of code here:

Day>pubday

So pubday = 31

//Add>pubday,1
Let>pubday=pubday+1

So pubday now equals 32. All you've done is added one to 31.

You've made pubday = 32.

You have NOT added one day to a DATE. You have added the number 1 to the number 31.

This would be better:

VBEval>Day(Now+1),pubday

This adds one day to the current date and returns the day portion.

So your script would be:

VBSTART
VBEND

//This to set the new name with ho code
VBEval>Day(Now+1),pubday
VBEval>Right("0"&"%pubday%",2),pubday
Month>pubmonth
let>EditionCode=ho
let>EditionDate=%pubmonth%%pubday%
let>Product=tvgrid
let>Newname=%EditionCode%%pubmonth%_%pubday%___%EditionCode%%pubmonth%%pubday%%Product%.pdf
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

timle
Pro Scripter
Posts: 96
Joined: Tue Apr 20, 2004 5:53 am

Thank you

Post by timle » Mon Feb 04, 2008 8:09 pm

Thank you

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