...

View Full Version : ASP help with SQL and dates



jimjamjo1
02-21-2007, 04:25 PM
Hey everyone, I am currently working on a project in ASP.

Ive been doing PHP for nearly 5 years now, and this is the first time i will be using ASP.

Im having a problem with the SQL.

You see, i have a table where i have some fields which include startdate and enddate which are dates.

I wish to extract the data which are valid for a particular day.

for example:

Query = "SELECT * FROM table WHERE enddate>today AND startdate<today"

where today = todays date....

But i cannot do it, can anyone help or point me in the right direction?

miranda
02-21-2007, 10:10 PM
Query = "SELECT * FROM table WHERE enddate>'" & Date() & "' AND startdate< '" & Date() & "'"

degsy
02-28-2007, 02:08 PM
What database are you using?

You can get the date function for the database from the help files.

SQL Server


Query = "SELECT * FROM table WHERE enddate > getDate() AND startdate < getDate()"


Access


Query = "SELECT * FROM table WHERE enddate > Now() AND startdate < Now()"

Baleric
03-01-2007, 02:58 AM
What database are you using?

Access


Query = "SELECT * FROM table WHERE enddate > Now() AND startdate < Now()"


'Now()' will returnt he date and time together,

i think he need to use 'Date()'

SSJ
03-01-2007, 10:08 AM
For Access, following code is better:



Query = "SELECT * FROM table WHERE enddate > Date() AND startdate < Date()"


-SSJ



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum