Focal Point
simple date add
September 24, 2007, 03:48 PM
MacLonghornsimple date add
This should be the easiest thing in the world. I'm trying to use dialog manager to set tomorrow's date:
-SET &MEASDATE = &DATE;
-SET &NEXTDATE = DATEADD(&MEASDATE,'D',1);
Result:
INVALID TYPE OF ARGUMENT #1 FOR USER FUNCTION DATEADD
Anyone?
(I HATE WF date handling)
Thanks.
Mark
WF 7.6 Windows
September 24, 2007, 04:03 PM
Francis MarianiUnfortunately, you have to convert the "alpha" Dialogue Manager date to a date field before using DATEADD.
E.G.:
-*-- Determine Period End Date 24 months prior to selected Period ---
-SET &DT24 =
- DATECVT( DATEADD(DATECVT(&F1V1,'I8YYMD','YYMD'),'M', -24),'YYMD','I8YYMD');
The inner DATECVT converts the DM variable to a date field, then DATEADD is applied, then the outer DATECVT converts the DATEADD result back to an alpha DM variable.
Your code:
-SET &MEASDATE = &YYMD;
-SET &NEXTDT1 =
- DATECVT( DATEADD(DATECVT(&MEASDATE,'I8YYMD','YYMD'),'D', 1),'YYMD','I8YYMD');
-SET &NEXTDT2 = CHGDAT('YYMD','MDY',&NEXTDT1,'A8');
-SET &NEXTDATE = EDIT(&NEXTDT2,'99/99/99');
-TYPE &MEASDATE - &NEXTDATE
I ALWAYS use YYMD formatted dates in calculations. You can always change the format for printing purposes
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 24, 2007, 04:25 PM
MacLonghornok, that's helpful. to add one more question though:
my initial date (&MEASDATE) is sometimes passed into the fex as mm/dd/yy string. How would I accomplish the same thing if I start with "9/24/07" for example?
Thanks.
Mark
WF 7.6 Windows
September 24, 2007, 04:41 PM
Francis MarianiSorry 'bout that.
-SET &MEASDATE = &DATE;
-*-- Strip the slash separator character
-SET &MEASDT1 = EDIT(&MEASDATE,'99$99$99');
-*-- Convert the variable to a Date, add a day, convert back to integer
-SET &NEXTDT1 =
- DATECVT( DATEADD(DATECVT(&MEASDT1,'I6MDY','YYMD'),'D', 1),'YYMD','I8YYMD');
-*-- convert from yymd to mdyy
-SET &NEXTDT2 = CHGDAT('YYMD','MDY',&NEXTDT1,'A8');
-*-- add date separator character
-SET &NEXTDATE = EDIT(&NEXTDT2,'99/99/99');
-TYPE &MEASDATE - &NEXTDATE
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
September 24, 2007, 04:42 PM
MacLonghornah yes... i was close...i wasn't using the '$' in EDIT. Thanks Francis.
Thanks.
Mark
WF 7.6 Windows
September 25, 2007, 12:30 AM
susannahfor DM dates, i use the AYMD and the AYM functions
-SET &TODAY = &YYMD ;
-SET &TOMORROW = AYMD( &TODAY, 1, 'I8YYMD');
We on the Point love FOCUS date functions, wttw.
there's an entire book on the subject, which you can order from the Tech Support site.
| In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID |
September 25, 2007, 10:05 AM
ihf-SET &DT1 = &YYMD ;
-SET &DT2 = AYMD(&YYMD ,1, 'I8' );
-TYPE TODAY: &YYMD TOMORROW: &DT2
-EXIT
note: you may need need to set DATEFNS
to put slashes or dashes you will need to add a few statements
Ira