Hi!
I think this should solve the problem
DECLARE @CurrentDate datetime
SET @CurrentDate = getDate()
SELECT * FROM tbl_test
WHERE datediff("d", CAST(Posted_Start AS datetime), @CurrentDate) <=0
AND
datediff("d", CAST(Posted_End AS datetime), @CurrentDate) >=0
The date range is inclusive of @CurrentDate
Reasoning: Getdate() function returns long date format.(including time
portion)
Regards,
CT Loo
Software Developer
> -----Original Message-----
> From: Bradford T Comer [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 04, 2003 5:40 AM
> To: SQL
> Subject: RE: Help : selecting records using a date range>
>
>
> oops i got that all wrong, but i think you got the point;
> check the BoL for BETWEEN if not.
>
> Sorry
> BTC
>
> >|> -----Original Message-----
> >|> From: Bradford T Comer [mailto:[EMAIL PROTECTED]
> >|> Sent: Tuesday, June 03, 2003 4:37 PM
> >|> To: SQL
> >|> Subject: RE: Help : selecting records using a date range>
> >|>
> >|>
> >|> Try Between, it works great for this...
> >|>
> >|> DECLARE @CurrentDate datetime
> >|> SET @CurrentDate = getDate()
> >|>
> >|> SELECT * FROM tbl_test
> >|> WHERE CAST(Posted_Start AS datetime) BETWEEN CAST(Posted_End AS
> >|> datetime)
> >|> AND @CurrentDate
> >|>
> >|> Or something similiar...i may be off, i thas been awhile...
> >|>
> >|> BTC
> >|>
> >|> >|> -----Original Message-----
> >|> >|> From: Bosky, Dave [mailto:[EMAIL PROTECTED]
> >|> >|> Sent: Tuesday, June 03, 2003 3:00 PM
> >|> >|> To: SQL
> >|> >|> Subject: Help : selecting records using a date range>
> >|> >|>
> >|> >|>
> >|> >|> I was trying to retrieve a list of records using a
> date range in
> >|> >|> SQL Server but can't seem to get the desired results.
> >|> >|> *** Posted_Start, Posted_End are VarChar types.***
> >|> >|>
> >|> >|> DECLARE @CurrentDate datetime
> >|> >|> SET @CurrentDate = getDate()
> >|> >|>
> >|> >|> SELECT * FROM tbl_test
> >|> >|> WHERE @CurrentDate >= CAST(Posted_Start AS datetime) AND
> >|> >|> CAST(Posted_End AS datetime) < @CurrentDate
> >|> >|>
> >|> >|> Any help would be nice!
> >|> >|>
> >|> >|> Thanks,
> >|> >|> Dave
> >|> >|>
> >|> >|>
> >|> >|>
> >|> >|>
> >|> >|>
> >|> >|> HTC Disclaimer: The information contained in this
> message may
> >|> >|> be privileged and confidential and protected from
> disclosure. If
> >|> >|> the reader of this message is not the intended
> recipient, or an
> >|> >|> employee or agent responsible for delivering this
> message to the
> >|> >|> intended recipient, you are hereby notified that any
> >|> >|> dissemination, distribution or copying of this
> communication is
> >|> >|> strictly prohibited. If you have received this
> communication in
> >|> >|> error, please notify us immediately by replying to
> the message
> >|> >|> and deleting it from your computer. Thank you.
> >|> >|>
> >|> >|>
> >|>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=6
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=6
Get the mailserver that powers this list at
http://www.coolfusion.com