View Single Post
  #1 (permalink)  
Old February 27th, 2006, 09:38 PM
nuttylife2 nuttylife2 is offline
Authorized User
 
Join Date: Feb 2006
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Calculate age from a varchar birthdate field

Hello there,
I have a birth date field in my database(which is a varchar field) and I need to calculate range of ages, I have tried to convert the varchar to datetime field directly in the database, but it is not letting me, then I tried various ways, one of them is below:

Select first_nm as 'First Name',last_nm as 'Last Name',
 Cast(DateDiff("mm", Convert(varchar(10),birthdt,101), Convert(varchar(10),GetDate(),101))/12 AS INTEGER) as age
I keep getting the error
"Syntax error converting datetime from character string"
Please help....!! I am going NUTS...!!
Reply With Quote