I would like to default the date in a pair of calendar controls in a report. For a given date (CurrentDate for example) the first calendar control would have the first day of the month set as default. The second caledar control would have the last day of the month set as default. These dates will be passed downstream as parameters to drill-down reports so I want to keep them in a date format. Does anyone have a way of computing the last day of the month as a Date?
Thanks
December 27, 2005, 01:45 PM
Kamesh
TRY THIS DEFINE FILE GGSALES CDAY/A4=DOWK(DATE,CDAY); LDT/I6YMD=AYMD(DATE,30,LDT); LDAY/A4=DOWK(LDT,LDAY); END
TABLE FILE GGSALES PRINT CDAY DATE LDT LDAY DM WHERE RECORDLIMIT EQ 1 END -EXIT
WFConsultant
WF 8105M on Win7/Tomcat
December 27, 2005, 09:30 PM
susannah
well, it depends. if you're going to do the date work in dialog manager, using your system date &YYMD for the current date for the beginning date: take the year and month of the current date and set the day to 01 for the ending date: add a full month to that result then subtract 1 day -SET &THISMONTH = EDIT(&YYMD,'999999'); -SET &NEXTMONTH = AYM(&THISMONTH,1,'YYM'); -SET &STARTDATE = &THISMONTH*100 + 1 ; -SET &ENDDATE = &NEXTMONTH*100 + 1; -SET &ENDDATE = AYMD ( &ENDDATE, -1, 'YYMD'); -TYPE &|STARTDATE = &STARTDATE &|ENDDATE = &ENDDATE and you get &STARTDATE = 20051201 &ENDDATE = 20051231
If you're going to define these dates in a file then first convert your system date to a focus smart date with the DATECVT function then use the DATEMOV function, which has cool operators to do all the heaving lifting for you. DEFINE FILE CAR THISDATE/I8YYMD WITH CAR= &YYMD ; TODAY/YYMD = DATECVT( THISDATE ,'I8YYMD' ,'YYMD' ) ; FIRST/YYMD = DATEMOV(TODAY,'BOM'); LAST/YYMD = DATEMOV(TODAY,'EOM'); END TABLE FILE CAR PRINT TODAY FIRST LAST END which gives you smart dates TODAY FIRST LAST 2005/12/27 2005/12/01 2005/12/31 Avoid using the DAYMD function, unless you need it. It produces a date using the microsoft epoch, which is 1 year different, very handy if you want to bring dates out of focus and into excel as real dates.This message has been edited. Last edited by: susannah,
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
December 29, 2005, 11:57 AM
Paul C.
I'm choosing the &variable path as querying my date table takes several seconds and my downstream use of the date is with an &variable. &variables in this case are fast except the return is in the Gregorian date format. The calendar control does not work with this format. It needs to be in mm/dd/yyyy format with the slashes.