Jump to content

Recommended Posts

Posted

Have an odd situation where subtracting one day from 20211201 ends up with an invalid date.

-SET &PREVDT = DATEADD(20211201, D, -1);

-SET &TEMP2 = 20211200;

Any ideas as to why DATEADD subtracting one day from the current date, when the current date was 20211201 would come up with a date of 20211200

Posted

This Focal Point post explains this issue. The date needs to be converted to an internal date format to work with DATEADD, then converted back to store in the variable. I find it simpler to use the AYMD function:

-SET &Yesterday = AYMD(&YYMD, -1, 'I8YYMD');

-TYPE Yesterday = &Yesterday

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...