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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

put day, month, year fields into date format in foxpro 1

Status
Not open for further replies.

rollypac

Programmer
Jun 13, 2003
23
0
0
US
My data started out in excel and then saved as a DB4 file. I have date, month and year fields that I need to put into yyyymmdd format. The month and date fields do not have leading zeros, the year is 4 digits. Any sugestions on how to create the format I need would be greatly appreciated.
 

If your date, month and year fields are numeric, you can simply use

dt=DTOS(DATE(nYear, nMonth, nDay))

to get yyyymmdd string,

or

SET CENTURY ON
SET DATE TO YMD
dt=DATE(nYear, nMonth, nDay)

to get date format yyyy/mm/dd.

If your values are character and you want a character string back, use

dt=dtYear+PADL(ALLTRIM(nMonth),2,'0')+PADL(ALLTRIM(nMonth),2,'0') to get yyyymmdd string.

To get a date from that, it would be

SET CENTURY ON
SET DATE TO YMD
dt=CTODdtYear+'/'PADL(ALLTRIM(nMonth),2,'0')+'/'+PADL(ALLTRIM(nMonth),2,'0'))


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top