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.
Author |
Topic |
fralo
Posting Yak Master
161 Posts |
Posted - 2010-12-08 : 08:25:59
|
I have two fields in the database.DATE - datetimeTIME - varchar(5) sample data: 23:24I need a query to get the most recent record inserted into the table. I have to combine these two fields together.I've been playing with something like this but I think I need some convert functions.SELECT MAX(DATE + ' ' + TIME)FROM TABLEAppreciate your help. |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-08 : 08:30:14
|
tryselect max(date + convert(datetime,time))==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
fralo
Posting Yak Master
161 Posts |
Posted - 2010-12-08 : 08:31:12
|
I get 'Conversion failed when converting datetime from character string.' |
 |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-08 : 08:42:34
|
check your time data - is it all nn:nn?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
fralo
Posting Yak Master
161 Posts |
Posted - 2010-12-08 : 08:45:04
|
Well I just scanned the data.Some are like this:nn:nn:but most are like nn:nn |
 |
|
|
|
|