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 |
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2010-06-24 : 13:52:17
|
| Hi, in my application I've Date like2010-06-11 11:54:32.683I've to find DateTime Before 12:00 O'Clock and DateTime After 12:00 Means 2010-06-11 11:54:32.683Will return 1st Shift2010-06-11 12:20:32.500Will return 2nd ShiftVB6/ASP.NET------------------------http://www.nehasoftec.com |
|
|
jorge_martin_hn
Starting Member
2 Posts |
Posted - 2010-06-24 : 14:35:36
|
| You can use in the where date between '2010-06-11' , '2010-0611 23:59:59'thats filter all of the day 11 |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-06-24 : 15:32:18
|
quote: Originally posted by jorge_martin_hn You can use in the where date between '2010-06-11' , '2010-0611 23:59:59'thats filter all of the day 11
You want to be careful when using BETWEEN and dates with times:DECLARE @Foo TABLE (date DATETIME)INSERT @FooSELECT '2010-06-11 23:59:59.995'SELECT *FROM @Foowhere date between '2010-06-11' AND '2010-06-11 23:59:59'-- BetterSELECT *FROM @FooWHERE Date >= '2010-06-11' AND DATE < '2010-6-12' |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-06-24 : 17:03:08
|
quote: Originally posted by ravininave Hi, in my application I've Date like2010-06-11 11:54:32.683I've to find DateTime Before 12:00 O'Clock and DateTime After 12:00 Means 2010-06-11 11:54:32.683Will return 1st Shift2010-06-11 12:20:32.500Will return 2nd ShiftVB6/ASP.NET------------------------http://www.nehasoftec.com
Please be more clear what you want to do.select a shift from a table or what? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
ravininave
Posting Yak Master
111 Posts |
Posted - 2010-06-25 : 00:34:09
|
quote: Originally posted by Lamprey
quote: Originally posted by jorge_martin_hn You can use in the where date between '2010-06-11' , '2010-0611 23:59:59'thats filter all of the day 11
You want to be careful when using BETWEEN and dates with times:DECLARE @Foo TABLE (date DATETIME)INSERT @FooSELECT '2010-06-11 23:59:59.995'SELECT *FROM @Foowhere date between '2010-06-11' AND '2010-06-11 23:59:59'-- BetterSELECT *FROM @FooWHERE Date >= '2010-06-11' AND DATE < '2010-6-12'
Very TrueI haven't use between. Actually I've to find shift so I'd writtenDate >= '2010-06-11'and Date <= '2010-06-11 11:59:59' FOR FIRST SHIFTFOR SECONDDate >= '2010-06-11 12:00:00'and Date <= '2010-06-11 23:59:59'THANXVB6/ASP.NET------------------------http://www.nehasoftec.com |
 |
|
|
|
|
|