Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Converting integer time

 
   Database Forums (Home) -> MSEQ RSS
Next:  Unhandled data type: TDS_INT8  
Author Message
Stan

External


Since: Feb 01, 2007
Posts: 6



(Msg. 1) Posted: Tue Jan 22, 2008 4:32 pm
Post subject: Converting integer time
Archived from groups: microsoft>public>sqlserver>mseq (more info?)

We have a SQL 2005 database that has the time stored as an integer. I'm
assuming it is the seconds after midnight. Is there a function to convert
this to a readable time?
Thanks
--
Stan Gosselin

 >> Stay informed about: Converting integer time 
Back to top
Login to vote
Russell Fields

External


Since: Feb 21, 2007
Posts: 457



(Msg. 2) Posted: Wed Jan 23, 2008 9:32 am
Post subject: Re: Converting integer time [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Stan,

Since SQL 2005 and earlier only has a datetime data type, then your time
needs to have a date. You can ignore the date as needed and deal only with
the time.

SELECT DATEADD(second, MySecondsColumn, 0);

Assuming that there were 12312 seconds, this would return:
1900-01-01 03:35:12.000

If you want to add the seconds to today's date, then:

SELECT DATEADD(second, MySecondsColumn,
-- Use date math to set the GETDATE time to 0
DATEADD(day, DATEDIFF(day,0,GETDATE()),0));

Whatever the date is, you can get the time by using the appropriate CONVERT
parameters. For example:

SELECT CONVERT(VARCHAR(12), DATEADD(second, MySecondsColumn,0),114)

RLF




"Stan" wrote in message

> We have a SQL 2005 database that has the time stored as an integer. I'm
> assuming it is the seconds after midnight. Is there a function to convert
> this to a readable time?
> Thanks
> --
> Stan Gosselin

 >> Stay informed about: Converting integer time 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Time out problem - Time Out Problem A single VB application links successfully to an SQL server. The application calls simple procedures to query the database. After 30s these queries timeout. If the timeout period is extended, all procedures return successfully. ..

time(urgent) - Hi How can i take time > hh:mmAM/PM and time < hh:mmAM/PM from a datetime field. please give me a sample query for this. -- Thanks

EXEC (select... ) problem Help! - How can I get this to work? declare @WkEmpID declare @sql varchar(1000) set @sql = 'select distinct @WkEmpID = EmpID from Employee' exec (@sql) Now this is a simplified version of a more comples query which is forcing me to use this method rather than...

Query returning multiple rows - Hi, I have a query that returns back rows that have multiple entries for a given UniqueID. I want the query to be expanded so that it then only returns 1 of the multiple rows based on the maximum date. Thefore, my return set looks like this: ..

Having a stored procedure copy tables & also preserve inde.. - Hello, I created a stored procedure that renames a table to OLD_xxxxx and replaces that table with another (copy) that resides on a different database. I pull the tablename names through the use of a cursor table and construct a SELECT INTO statement a...
   Database Forums (Home) -> MSEQ All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]