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 |
|
dewacorp.alliances
452 Posts |
Posted - 2008-04-21 : 16:29:39
|
| Hi thereI am using SQL2005 and would like to check the whether the time is within the valid range for instance:Data to check: 2:15AMRange is between: 01:00AM till 06:59AM, 07:00AM till 02:00 PM I can use the datepart for hh but that is not what I want. I want to have a full time: HH:MM cause sometimes if you do datepart by hour and if you apply into the above excample will be:2 BETWEEN 1 AND 6 (this is ok)2 BETWEEN 7 AND 2 (this is not ok)Any idea? |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-04-21 : 16:44:47
|
datepart(hour, @date) returns an int between 0 and 23. so your second check should be this:datepart(hour, mydatecolumn) between 7 and 14 elsasoft.org |
 |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2008-04-21 : 17:47:19
|
actually probably needs to be between 7 and 13.  elsasoft.org |
 |
|
|
dewacorp.alliances
452 Posts |
Posted - 2008-04-21 : 19:22:34
|
Hi thereI think you are right it actually returns 0-23. My mistake.Thanksquote: Originally posted by jezemine actually probably needs to be between 7 and 13.  elsasoft.org
|
 |
|
|
|
|
|