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

Datetime conversion

Status
Not open for further replies.

lyudmila

Programmer
Oct 18, 2002
54
US
Is it posissible to convert string '62001' to datetime format? And how?
 
If you don't know what 62001 is supposed to be, how can we figure it out?

62001 could be June 2001, but it could also be June 20, 2001 (6/20/01).

-SQLBill
 
declare @x as datetime
SET @x = convert(datetime,left('62001',len('62001')-4) + '/01/'+ right('62001',4))

print @x
 
This would be if June 1, 2001 was the right answer....
but that's for you to figure out...
 
This could be a straight 62001 days since '01 Jan 1900' also. I agree with the very good knowledge of SQLSister and SQLBill and think you need to understand the meaning of 62001 before trying to CONVERT or CAST it to a date.

Rhys

Be careful that the light at the end of the tunnel isn't a train coming the other way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top