Focal Point
Date arithmetic in dialog manager

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5231049361

April 17, 2006, 05:09 PM
yogi
Date arithmetic in dialog manager
Hello

I was wondering if anyone has done date calculations using DIALOG MANAGER.

I want to find the date from 1 month before today.

-SET &MTHDT = DATEADD(&TDAY1, 'M', -1)

But DATEADD function does not work with DIALOG MANAGER.
In past I had used AYMD function to find a date from searched date, but cant use in this scenario since I do not know if the month has 30 days or 31 days or 28 days.

Does anyone has any idea how to find the date before 1 month from searched date using using Dialog manager? Any help will be appreciated.


Thanks

ya
April 17, 2006, 05:16 PM
<Tim Howard_ABCBS>
I know there have been a few posts on this in the past, you might want to search to find more information. You can use the following syntax to do what you're trying to do:

-SET &DATETMP = DATECVT((DATEADD((DATECVT(&DATEIN, 'I8YYMD', 'YYMD')),'M', -6)),'YYMD','I8YYMD');

I think I got this syntax from one of the old posts myself.
April 17, 2006, 05:39 PM
susannah
Yogi, you can use the AYMD function to add or subtract days from dialog manager date variables.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
April 17, 2006, 06:06 PM
yogi
Susan
I cant use AYMD because I dont know if month has 30 days or 31 days. And then we also have a month with 28 days which mess up everything. Smiler

I will play with TIm's solution. THis might work.

Thanks
April 18, 2006, 06:35 AM
Tony A
Yogi,

Tim's solution will work for you in DM for the simple reason that the inner most DATACVT is ensuring that the date you are using is converted into a non-legacy date format. This is what DATEADD requires, not the usual legacy date, and is usually where things go wrong for folks. The outer DATECVT ensures that the DATEADD output (which exists as a count of days since base date - 31/12/1900) is formatted as a legacy date once more.

It is always best to look at the help files when using date functions and pay particular attention to the type of format that a function requires.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 19, 2006, 05:27 AM
<Special-K>
Yogi

You DO know how many days the previous month has.

If you subtract the number of days into this month from today, e.g. today is 20060419 take off 19 days that will give you the last date of the previous month!

-SET &TDAY = &YYMD;

-SET &DAYS1=EDIT(&TDAY,'$$$$$$99');
-SET &DAYS2=&DAYS1 * -1;
-SET &DATE1=AYMD(&TDAY,&DAYS2.EVAL,'I8YYMD');

-TYPE &TDAY &DAYS1 &DAYS2 &DATE1

&DATE1 will be the last day of the previous month
April 20, 2006, 01:49 PM
yogi
Tim's solutions worked. You ROCK !!!

Thanks everyone.