473,387 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.

Mar 20 '07 #1
3 9817
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()
Mar 20 '07 #2
On Mar 20, 4:33 pm, Ed Murphy <emurph...@socal.rr.comwrote:
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!!!

Mar 20 '07 #3
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" <t8*****@gmail.comwrote in message
news:11**********************@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.

Mar 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Matthew Roberts | last post by:
To all SQL gurus: I have a Windows Service that uses a single SQL Server table to retrieve items of work. Each thread of the service checks this table for the earliest item of work that is not...
6
by: Chad A. Beckner | last post by:
Does anyone know how to make common database connections "common" in all aspx files? In other words, instead of creating a SQLConnection, then a DataAdapter in every ASPX file for my application,...
8
by: Chris | last post by:
I know the reason why I get an error when the fields are set to null, but I'm working with old data that contains them. Any quick fixes? was hoping to avoid writing out every field in sql statement...
3
by: Alan | last post by:
I'm having brain fade today... Can the recordsource in a Form's properties do more than one select statement based on criteria? On a popup subform I'm trying to display matching records from a...
0
JamieHowarth0
by: JamieHowarth0 | last post by:
I'm about to set up a new website, powered by DotNetNuke (my favourite CMS at the moment, mainly because it's free), and I want to install a Counter-Strike game server onto the same machine. I also...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.