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-06-12 : 08:01:31
|
| SouriRajan writes "pplthis is my requirement. i have tried so many variations of BETWEEN, but not sure whether it gives the correct answer.i have a photo album with date based validity. ie, the user who creates the album will set a validation period, for ex, album1 is valid only from 14/06/2002 to 20/06/2002. how can i check the album which i am going to display now is valid by today's date?i tried "Select * FROM tblAlbums WHERE getdate() BETWEEN FDate AND TDate"but not so sure its the correct way.thanks in advance." |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2002-06-12 : 08:06:03
|
| as long as its valid on the start and end date then this is fine...PeaceRick |
 |
|
|
dataphile
Yak Posting Veteran
71 Posts |
Posted - 2002-06-12 : 10:16:01
|
| The only thing that you need to keep in mind is that BETWEEN is inclusive. |
 |
|
|
solart
Posting Yak Master
148 Posts |
Posted - 2002-06-17 : 11:48:16
|
| It seems to me that if you are using "between" where only the dates are specified that you might actually not get the entries corresponding to the "end" date. Consider the following from Books On line:Using Date and Time DataMicrosoft® SQL Server™ 2000 has the datetime and smalldatetime data types to store date and time data.There are no separate time and date data types for storing only times or only dates. If only a time is specified when setting a datetime or smalldatetime value, the date defaults to January 1, 1900. If only a date is specified, the time defaults to 12:00 A.M. (Midnight).I think this means, say that the between dates are '03/05/02' and '03/08/02', that if the datetime you are actually comparing is '03/08/02 10:00 A.M.', then this may fail the "end" date compare since the time associated with the "end" date is 12:00 A.M.If my interpretation is incorrect, then my apologies.Solart |
 |
|
|
|
|
|