Coverting String to Date in Form Code

  • Thread starter Thread starter MAB
  • Start date Start date
M

MAB

I have birthdates in a table that are expressed as strings. For example
April 4, 2003 is "04042003". I would like to convert this string data to a
date in code so that I can use it to do calculations such as determining a
person's age. To calculate the age is very simple, but I can't seem to find
a way to convert "04042003" to a date that I can do calculations on. Is
there a simple method for doing so? Thanks for your help!
 
MAB said:
I have birthdates in a table that are expressed as strings. For example
April 4, 2003 is "04042003". I would like to convert this string data to a
date in code so that I can use it to do calculations such as determining a
person's age. To calculate the age is very simple, but I can't seem to find
a way to convert "04042003" to a date that I can do calculations on. Is
there a simple method for doing so? Thanks for your help!

You picked a pretty lousy example date. Is the first "04" the month or the
day? The code below assumes it's the month.

ActualDate: DateSerial(Right([YourField],4),Left([YourField],2),
Mid([YourField],3,2))
 
Back
Top