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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-11-13 : 08:56:37
|
| Chun writes "I am trying to query for records between 2:30am to 5:00am. The best I can do is :Select RingTimeFrom CallHistory Where ((DatePart(hh, RingTime) Between '3' AND '4' ) or ((DatePart(hh, RingTime) = 2 ) AND (DatePart(minute, RingTime) Between 30 AND 59 )) ) 2002-01-13 02:44:02.0002002-01-13 02:54:24.0002002-01-13 03:01:28.0002002-01-13 03:23:49.0002002-01-13 03:24:22.0002002-01-13 03:36:32.0002002-01-13 04:21:03.0002002-01-13 04:45:29.0002002-01-13 04:56:07.0002002-01-14 02:56:41.0002002-01-15 02:51:47.0002002-01-15 03:28:40.0002002-01-15 03:36:17.0002002-01-15 03:38:57.0002002-01-15 03:39:45.0002002-01-15 03:40:01.0002002-01-15 03:43:07.0002002-01-15 03:47:14.0002002-01-15 03:47:26.0002002-01-15 03:50:05.0002002-01-15 04:03:30.0002002-01-15 04:29:10.0002002-01-16 03:00:17.0002002-01-19 03:03:16.0002002-01-19 03:51:14.000Question 1: Is there a better sql statement than this?Question 2: What if I would like the records from 22:30pm to 02:00am?Please send to "ChunPan9@yahoo.com". Thanks." |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-11-13 : 09:17:15
|
| where convert(char(5),RingTime,114) between '02:30' and '05:00'where convert(char(5),RingTime,114) >= '22:30'or convert(char(5),RingTime,114) <= '02:00'==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.Edited by - nr on 11/13/2002 09:17:57 |
 |
|
|
|
|
|