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

Conversion of Number to Date Format

Status
Not open for further replies.

sms28

IS-IT--Management
Dec 10, 2002
19
US
I have a table with a field, DOB, defined as a number. This field is date of birth. For example, the data appears as 19860302 - I need this to be 03/02/1986 in date format. Any ideas how I can accomplish?

Thanks in advance.
 
is this a one time thing, and is the field a numeric field or text?
 
newdob = mid(dob,5,2) & "/" & Right(dob,2) & "/" & Left(dob,4)
 
Thanks. The suggestion from grnzbra worked.
 
Wonderful how everyone just jumps in whithout knowing the details. Glad it helped.
 
This works so far - ie makes it look like a date, but trying to use datediff using this newdob field doesn't.
Any thoughts?
 
cdate(newdob)

The cdate converts the string to a date. So if you use datediff, you would do it like this:

datediff(yyyy, cdate(newdob),now())

Not sure how you want to use it. This is just an example.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top