Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Format 2

Status
Not open for further replies.

Phil Thoms

Programmer
Oct 31, 2005
245
GB
Is there a quick way or a function in VFP 6 which displays dates in the following format:- 19JAN2014

Thanks for your help.
 
?MyDate( date() )
? MyDate( SomeDateField )

Function MyDate(tdDate)
return trans(day(tDate)) + upper(substr(cMonth(tDate),1,3)) + transform(year(tDate))
Endfunc

Not Tested.


Ez Logic
Michigan
 
^^ that should be:

Function MyDate([highlight #CC0000]tDate[/highlight])

Ez Logic
Michigan
 
Also, for the day, if you want to display "01JAN2014',

YOU have to PADL() the Day with '0' and make sure your Set Century is on.

like this:

Function MyDate(tDate)
local lcOCentury, lcRetDate
lcOCentury = Set('century')
set century on
lcRetDate = PADL( TRANS( DAY(tDate) ),2,'0') + UPPER(SUBSTR(CMONTH(tDate),1,3)) + TRANSFORM(YEAR(tDate))
Set century &lcOCentury
return lcRetDate


Ez Logic
Michigan
 
^ Mike, Beautiful, i never used Transform like that in conjuction with padl()

Beautiful!

Ez Logic
Michigan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top