Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi i would like to know if i have an identity number as follows (780539878676) as a varchar and i want to pull out the first 6 characters and get the age from this identity number how do i do that? in SQL 2005
Posted

1 solution

select substring('780539878676', 1,6) gets you the first 6 characters. However, to what age do you refer? Where in that string is a date stored? Please clarify.
 
Share this answer
 
Comments
allaparaclatus 10-Aug-10 4:12am    
Thank you, the First 2 (Two) digits are the year of Birth thats 78 is the Birth year.
R. Giskard Reventlov 10-Aug-10 5:05am    
so just do substring(foo, 1,2) to get the age if that's what you need.
allaparaclatus 10-Aug-10 6:40am    
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900