Jump to content
Macro Express Forums

Bug In Dates


randallc
 Share

Recommended Posts

Hi,

I think I have a bug in dates;

Date/Time: Save "dd" into %T3%

Variable Modify String: Convert %T3% to integer %N2%

Variable Modify Integer: %N2% = %N2% - 4

Repeat Start (Repeat 10 times)

  Variable Modify Integer: %N3% = %N2% + %N1%

  Date/Time: Save "dddd, d MMMM yyyy" into %T99%

  Variable Modify String: Append "|%N3%==%T99%" to %T1%

Repeat End

Text Box Display: first

<DT:ddT:03:1:><TMVAR2:05:03:02:000:000:><NMVAR:02:02:1:0000002:2:0000004><REP3:01:000001:000001:00010:1:01:><NMVAR:01:03:1:0000002:1:0000001><DT:dddd, d MMMM yyyyT:99:3:{P0%N3%}{F00001}{F00000}{F00000}><TMVAR2:07:01:00:000:000:|%N3%==%T99%><ENDREP><TBOX4:T:1:000277000257000458000263:000:firstT1=%T1%; >

Gives

T1=|14==Friday, 3 June 2005|15==Thursday, 2 June 2005|16==Wednesday, 1 June 2005|17==Monday, 30 May 2005|18==Sunday, 29 May 2005|19==Saturday, 28 May 2005|20==Friday, 27 May 2005|21==Thursday, 26 May 2005|22==Wednesday, 25 May 2005|23==Tuesday, 24 May 2005;

31st May is missing!

Can anyone help?

Best, Randall

Link to comment
Share on other sites

Randall -

 

The problem is in the logic. Your Date/Time Save command subtracts the %N3% variable and then adds 1 month in order to get the %T99% result. So, when %N3% = 17 you are saying: Subtract 17 days from May-17-2005, which then equals Apr-30-2005, and now add 1 month, which equals May-30-2005.

 

You must be very careful adding or subtracting anything other than days using Macro Express date strings. You need to into account that months contain between 28 and 31 days. The {DateTime - Go Months} macro within the PGM Functions Library handles these extremes very nicely. For example if today's date was Jan-31-2005 and you used the {DateTime - Go Months} macro to add one month, the result would be Feb-28-2005.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...