Unix Technical Forum

Quick SQL Select Statement ?

This is a discussion on Quick SQL Select Statement ? within the SQL Server forums, part of the Microsoft SQL Server category; --> I am using SQL Server Express and ASP. I have a table that contains news articles, headlines, start and ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-01-2008, 02:43 PM
t8ntboy
 
Posts: n/a
Default Quick SQL Select Statement ?

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2008, 02:43 PM
Ed Murphy
 
Posts: n/a
Default Re: Quick SQL Select Statement ?

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()
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2008, 02:43 PM
t8ntboy
 
Posts: n/a
Default Re: Quick SQL Select Statement ?

On Mar 20, 4:33 pm, Ed Murphy <emurph...@socal.rr.com> wrote:
> 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!!!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-01-2008, 02:43 PM
AlterEgo
 
Posts: n/a
Default Re: Quick SQL Select Statement ?

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@gmail.com> wrote in message
news:1174421409.303027.198580@l75g2000hse.googlegr oups.com...
>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.
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:56 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com