Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 convert time varchar to date

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2012-08-20 : 14:21:20
i have a time like
48:30.0

I am doing
select convert(datetime,'48:30.0',108)

but getting

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.


what am I doing wrong and what is the correct way of doing this?

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-08-20 : 14:25:42
What time system are you on? That looks like a Metric day, which SQL server doesn't support. (BTW, Metric Day is a joke about days having 100 hours).

If you look at the format for 108 it's: hh:mi:ss. Where the Hour needs to be between 1 and 23.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-08-20 : 17:27:35
how did you get the current time value? its not a valid value that can be stored in datetime compatible field

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -