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 |
|
Amjath
Yak Posting Veteran
66 Posts |
Posted - 2007-07-26 : 06:01:05
|
| Hi All,i had 1 doubt regarding the between in sql serverwhen i between in sqlserver it means it includes that date alsofor exampleselect * from tbltest where joindate between '1/2/2002' AND '2/2/2002'in this case joindate having 2-2-2202 09:30:01.000 is not coming why is it like thiswhat is need to add to get 2-2-2202 09:30:01.000 in betweenWith RegardsAmjath |
|
|
shallu1_gupta
Constraint Violating Yak Guru
394 Posts |
Posted - 2007-07-26 : 06:05:27
|
| As per the statement it will fetch all the records between date 1/2/2002 00:00:00.000 and 2/2/2002 00:00:00.000select * from tbltest where joindate between '1/2/2002' AND '2/2/2002'if you want to include time part as well. then you need to set it asselect * from tbltest where joindate between '1/2/2002' AND '2/2/2002 23:59:59.999' |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2007-07-26 : 08:10:38
|
This is the usual way to do a date range query:>= start_datetime and < end_datetimeAlso, date format YYYYMMDD hh:mm:ss.mil is the only unambiguous format for a date string.Example: '20071231 23:59:59.997' or just '20071231' for the date.select *from tbltest where joindate >= '20020201'' and joindate < '20020203' CODO ERGO SUM |
 |
|
|
|
|
|