![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
I was trying to retrieve all the records from a table, Crates that fall within a particular date range for the field ShipDate, which is of type datetime. What I have noticed is that the lower bound is inclusive while the upper bound is not. For example, in this query, I have noticed that ship dates from 4/5/07 to 4/17/07 are included while ship dates from 4/18/07 are not: SELECT * FROM Crates WHERE (ShipDate IS NOT NULL) AND (ShipDate > '4/5/07') AND (ShipDate < '4/18/07') ORDER BY ShipDate I have also found that substiting > for >= and < for <= returns the exact same results. One solution would be to increase the upper bound by one day. However, I still find this strange. Is there a optimal way for dealing with date ranges with SQL Server 2005. Thanks, Aaron |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
I was reading the article and was unable to get some of queries to execute. Can anyone help get these to work: How to get the last day of the previous month? And the last day of the current month? SELECT DATEADD(month, DATEDIFF(month, '20000101', CURRENT_TIMESTAMP), '19991231') SELECT DATEADD(month, DATEDIFF(month, '20000101', CURRENT_TIMESTAMP), '20000131') |
#6
| |||
| |||
|
|
How to get the last day of the previous month? And the last day of the current month? |
|
I was reading the article and was unable to get some of queries to execute. Can anyone help get these to work: How to get the last day of the previous month? And the last day of the current month? SELECT DATEADD(month, DATEDIFF(month, '20000101', CURRENT_TIMESTAMP), '19991231') SELECT DATEADD(month, DATEDIFF(month, '20000101', CURRENT_TIMESTAMP), '20000131') Thanks, Aaron |
#7
| |||
| |||
|
|
I was reading the article and was unable to get some of queries to execute. Can anyone help get these to work: How to get the last day of the previous month? And the last day of the current month? SELECT DATEADD(month, DATEDIFF(month, '20000101', CURRENT_TIMESTAMP), '19991231') SELECT DATEADD(month, DATEDIFF(month, '20000101', CURRENT_TIMESTAMP), '20000131') |
![]() |
| Thread Tools | |
| Display Modes | |
| |