March 31, 2009 at 1:00 pm
could any body help me out , i have two columns one is "datetime" which is storing date and other is "int" which is storing time , now i need to club them and compare with system date for one of the procedure , any direction is appreciated.
March 31, 2009 at 1:04 pm
It would help if you could provide the DDL (CREATE TABLE statement) for the table, some sample data, and the expected results based on the sample data.
March 31, 2009 at 1:40 pm
Hi
Maybe this thread is alike your request:
http://www.sqlservercentral.com/Forums/Topic685851-338-1.aspx
Greets
Flo
April 1, 2009 at 6:07 am
simplest way you can use is like this -
Example -
Create Table #Test(dt datetime , tm int)
Insert into #Test values(getDate(),1)
Insert into #Test values(getDate(),2)
Insert into #Test values(getDate(),3)
Insert into #Test values(getDate(),4)
Insert into #Test values(getDate(),5)
Select cast(dt as varchar) + ':' + cast(tm as varchar) From #TEST
But again it depends what your table structure is and how you storing date and time in the table.
MJ:cool:
April 2, 2009 at 9:05 am
What does the time integer represent? Is it 0 - 2359, where 1061 would never exist? 1000 - 2459? Is it the time converted to minutes (hour of day * 60 + minutes past hour)? Time converted to seconds? Please provide more info!
April 2, 2009 at 5:26 pm
Thanks for your reply. sdate in datetime and stime in seconds
"sdate" "stime"
"2009-04-18 00:00:00.000" "59002"
i am not sure how i can really convert and merge both after i convert stime to hours or mins(by dividing 3600 or 60) so i can compare the same with getdate() that gives me correct date and time difference.
sorry new to this so if asking too many question.
April 3, 2009 at 4:23 am
Try: DATEADD(ss, stime, sdate)
(and after trying be sure to lookup "DATEADD" in the Books On-Line!)
April 3, 2009 at 8:23 pm
You rock , that worked ,thanks much.
thanks to all who responded to help!!
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply