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 2005 Forums
 Transact-SQL (2005)
 Converting and fortmatting Time

Author  Topic 

vqcheese
Starting Member

19 Posts

Posted - 2009-05-01 : 14:09:41
I have a field in my database called timearrived_i. When the program puts the data into this field its put in there like this 1200p, 0600a, 0600p, ect... Is there away i can get that to to format like in normal time format?

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-05-01 : 15:09:17
There is no time format in SQL 2005, the changes should be made to the front end.
select left(@time,2) + ':' + substring(@time,3,2) will amke it look more like a time
and
select dateadd(hh,convert(int,left(@time,2)),0)
will make it an actual time, but you;d have to change the data type in the table, or add a new field to store it.

Jim
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-02 : 03:08:13
SELECT CAST(STUFF(timearrived_i, 3, 0, ':') + 'm' AS DATETIME)
FROM Table1



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -