I need to compare two dates (i.e. date1 >= date2 or Date1 <= Date2) and thought I would see if someone has some code they might share.
Thanks.
Manny
Thanks.
Manny

MACRO YYYYMMDD_to_Numeric (dt) = VAL(LEFT$(dt,4) & MID$(dt,6,2) & RIGHT$(dt,2)) MACRO YYYYMMDD_Diff (dt1, dt2) = YYYYMMDD_to_Numeric(dt2) - YYYYMMDD_to_Numeric(dt1) FUNCTION PBMAIN () AS LONG LOCAL r1,r2 AS STRING r1 = "2009-08-16" r2 = "2009-12-31" ? STR$(YYYYMMDD_Diff (r1,r2)) END FUNCTION
DECLARE SUB month(dte$,mnth$) FUNCTION PBMAIN () AS LONG DIM dt AS STRING ' original date DIM dt2 AS STRING ' original date DIM dt1 AS LONG ' re-arranged date DIM dt3 AS LONG ' re-arranged date DIM dte$, mnth$ ' Date 1 'dt = "2008-12-29" dt = "19-JAN-2007" dte$ = dt mnth$ = "" CALL month (dte$,mnth$) dt = RIGHT$(dt,4) & mnth$ & LEFT$(dt,2) dt = LEFT$(dt,4) & MID$(dt,5,2) & RIGHT$(dt,2) dt1 = VAL(dt) ' Date 2 'dt2 = "2009-12-31" dt2 = "28-MAY-2008" dte$ = dt2 mnth$ = "" CALL month (dte$,mnth$) dt2 = RIGHT$(dt2,4) & mnth$ & LEFT$(dt2,2) dt2 = LEFT$(dt2,4) & MID$(dt2,5,2) & RIGHT$(dt2,2) dt3 = VAL(dt2) PRINT dt1, dt1 - dt3 PRINT dt3, dt3 - dt1 dte$ = "" mnth$ = "" WAITKEY$ END FUNCTION SUB month(dte$, mnth$) dte$ = MID$(dte$, 4,3) SELECT CASE dte$ CASE "JAN" mnth$ = "01" CASE "FEB" mnth$ = "02" CASE "MAR" mnth$ = "03" CASE "APR" mnth$ = "04" CASE "MAY" mnth$ = "05" CASE "JUN" mnth$ = "06" CASE "JUL" mnth$ = "07" CASE "AUG" mnth$ = "08" CASE "SEP" mnth$ = "09" CASE "OCT" mnth$ = "10" CASE "NOV" mnth$ = "11" CASE "DEC" mnth$ = "12" CASE ELSE mnth$ = "No Match" END SELECT END SUB
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment