dbTalk Databases Forums  

Quick SQL Select Statement ?

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Quick SQL Select Statement ? in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
t8ntboy
 
Posts: n/a

Default Quick SQL Select Statement ? - 03-20-2007 , 02:10 PM






I am using SQL Server Express and ASP.

I have a table that contains news articles, headlines, start and end
dates. I am trying to create a recordset that shows all of the
articles that are greater than or equal to the start date and less
than or equal to the end date. For some reason I cannot get it to
function properly using a statement similar to StartDate >= Now() AND
EndDate <= Now(). SQL doesnt like the Now() piece of the statement.
Anyone have an idea how I can get this to work? I have also tried
CURDATE() but to no avail.


Please help.


Reply With Quote
  #2  
Old   
Ed Murphy
 
Posts: n/a

Default Re: Quick SQL Select Statement ? - 03-20-2007 , 02:33 PM






t8ntboy wrote:

Quote:
I am using SQL Server Express and ASP.

I have a table that contains news articles, headlines, start and end
dates. I am trying to create a recordset that shows all of the
articles that are greater than or equal to the start date and less
than or equal to the end date. For some reason I cannot get it to
function properly using a statement similar to StartDate >= Now() AND
EndDate <= Now(). SQL doesnt like the Now() piece of the statement.
Anyone have an idea how I can get this to work? I have also tried
CURDATE() but to no avail.
StartDate <= GetDate() and EndDate >= GetDate()


Reply With Quote
  #3  
Old   
t8ntboy
 
Posts: n/a

Default Re: Quick SQL Select Statement ? - 03-20-2007 , 02:42 PM



On Mar 20, 4:33 pm, Ed Murphy <emurph... (AT) socal (DOT) rr.com> wrote:
Quote:
t8ntboy wrote:
I am using SQL Server Express and ASP.

I have a table that contains news articles, headlines, start and end
dates. I am trying to create a recordset that shows all of the
articles that are greater than or equal to the start date and less
than or equal to the end date. For some reason I cannot get it to
function properly using a statement similar to StartDate >= Now() AND
EndDate <= Now(). SQL doesnt like the Now() piece of the statement.
Anyone have an idea how I can get this to work? I have also tried
CURDATE() but to no avail.

StartDate <= GetDate() and EndDate >= GetDate()
Ed:

Many thanks!!!



Reply With Quote
  #4  
Old   
AlterEgo
 
Posts: n/a

Default Re: Quick SQL Select Statement ? - 03-20-2007 , 04:02 PM



t8ntboy,

You might want to use CURRENT_TIMESTAMP which is ANSI compliant and
equivalent to GETDATE(). There is no functional difference, its just easier
for someone coming from another DB platform to understand.

-- Bill

"t8ntboy" <t8ntboy (AT) gmail (DOT) com> wrote

Quote:
I am using SQL Server Express and ASP.

I have a table that contains news articles, headlines, start and end
dates. I am trying to create a recordset that shows all of the
articles that are greater than or equal to the start date and less
than or equal to the end date. For some reason I cannot get it to
function properly using a statement similar to StartDate >= Now() AND
EndDate <= Now(). SQL doesnt like the Now() piece of the statement.
Anyone have an idea how I can get this to work? I have also tried
CURDATE() but to no avail.


Please help.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.