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 |
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-06-12 : 07:08:05
|
| Hi,I have 1 date field where im interested in the time.i.e. 2009-01-01 17:30:00.000The query I need to write is as followscase when (convert(varchar, datefield1, 108) > '17:00:00') THENdatefield1 - '2009-01-01 17:00:00.000'But I get error operand error converting character string for substract function.I basically want if the time is after 5, get the difference in time between the field and 5pm.ThanksC |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-12 : 07:13:14
|
case when (convert(varchar(8), datefield1, 108) > '17:00:00') THEN DATEDIFF(MINUTE, '2009-01-01 17:00', datefield1) E 12°55'05.63"N 56°04'39.26" |
 |
|
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2009-06-12 : 07:46:57
|
hi,Thanks for the prompt reply, how would I be able to get the minute count from time?Minute(datetime1)???quote: Originally posted by Peso case when (convert(varchar(8), datefield1, 108) > '17:00:00') THEN DATEDIFF(MINUTE, '2009-01-01 17:00', datefield1) E 12°55'05.63"N 56°04'39.26"
|
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-12 : 08:50:53
|
The 1. Absolute minute value? 17:45 -> 452. Number of minutes since last minute? 17:45 -> 1065 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|
|
|