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

Changing the appearance of a Date

Status
Not open for further replies.

10four

Programmer
Jun 19, 2002
1
US
In my report I have a birth date field that displays the dates as 1968-22-10. I need it to display 10/22/68. I can't just format the field to look like that because it's set up as a character in the database and not as a date time field. Any help would be great.

Thanks
 
Use the following formula to convert your field to a date.

stringvar dat:={your.date.field}
date(val(dat[1 to 4]),val(dat[9 to 10]),val(dat[6 to 7])) Mike

 
I had this same problem since our database also displays year first. I solved with the formula that follows:

{date.field}[5 to 6] + "/"+
{date.field}[7 to 8] + "/"+
{date.field}[1 to 4]
 
Consider converting it to a proper date (and evicerating your DBA ;) )

cdate({date.field}[1 to 4]+"/"+{date.field}[9 to 10]+"/"+{date.field}[6 to 7]))

You may find better performance by offloading this function to your database using a SQL Expression, if that's a concern.

Converting allows for formatting a real date field and also allows for proper date functions (sorting, date arithmetic, etc.).

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top