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

Change the appearance of a date field

Status
Not open for further replies.

cknapp

Technical User
May 22, 2001
10
0
0
US
I have a field that appears as follows 920825 - i need it to display as a date field as 08/25/92. Suggestions?
 
this currently a numeric field
 
What version of Crystal Reports? What data type is the field (numeric or string)? In converting this to a date field, you will also need to decide the basis for converting 2 digit years to 4 digit years - ie 50 to 99 converts to 1950 to 1999, 0 to 49 converts to 2000 to 2049. Malcolm Wynden
I'm for sale at malcolm@wynden.net
 
version 8 - converting to a 2 digit year
 
Crystal is quite happy to use just a two digit year - it just assumes that the first two digits are 00. Usually this is not a great idea is you are intending the first two digits to be 19 or 20, because the sort order does not reflect the century portion of the date. In some situations, such as employee birthdates, it is not an issue (yet).

StringVar DateTest := ToText({YourNumericField},"000000") ;
Date(Val(DateTest[1 to 2]),Val(DateTest[3 to 4]),Val(DateTest[5 to 6])) ;
will give you dates without a century value.
The follow function uses 50 as the cutoff point to determine which century value to use.
DateTo2000 ((Date(Val(DateTest[1 to 2]),Val(DateTest[3 to 4]),Val(DateTest[5 to 6]))),50 )
Malcolm Wynden
I'm for sale at malcolm@wynden.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top