DMY(), MDY()
DMY() returns a character string in the form day-month-year, and MDY returns month-day-year, when supplied with a date or datetime variable.
Usage |
lcDateToDisplay = DMY( dDate | tDateTime ) lcDateToDisplay = MDY( dDate | tDateTime ) |
* GoodDmy.PRG - return a prettier DMY value * Parameter: tdDate - a date or datetime value * default - today's date * Returns: String of form DD Mmmmmm YYYY PARAMETER tdDate IF EMPTY(tdDate) OR NOT INLIST(type('tdDate'),"D","T") tdDate = DATE() ENDIF RETURN PADL(DAY(tdDate),2) + " " + ; CMONTH(tdDate) + " " + ; STR(YEAR(tdDate),4)MDY() returns a character string in the form MMM DD, YY (or YYYY, depending on SET CENTURY). Like the DMY() function, this one isn't too smart, preceding single-digit dates with a zero, and displaying years as two-digit numbers if CENTURY is set OFF. A better version is:
* GoodMDY.PRG - return a prettier MDY value * Parameter: tDate - a date or datetime value * default - today's date * Returns: String of form Mmmmmm DD, YYYY PARAMETER tdDate IF EMPTY(tdDate) OR NOT INLIST(TYPE('tdDate'),"D","T") tdDate = DATE() ENDIF RETURN CMONTH(tdDate) + " " + ; LTRIM(STR(DAY(tdDate))) + ", " + ; STR(YEAR(tdDate),4)
Example |
? DMY({03/18/1954}) && returns "18 March 1954" ? DMY({01/01/01}) && returns "01 January 01" with CENTURY OFF ? MDY({03/18/1954}) && returns "March 18, 1954" |
See Also |
Day(), Dow(), Date(), DateTime(), GoMonth(), Month(), Set Century, Set Date, Set Mark To, Year() |