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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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. |
| |||
| 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() |
| |||
| 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!!! |
| ||||
| 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. > |