Now() function in SQL??

J

Jerome

Hi,

Before I've queried my Access DB using ASP pages. The SQL string then
could contain: SELECT * FROM table1 WHERE date1>=Now().

This time round my DB is on a SQL Server and I'm still using ASP for
this. But now the Now() function returns an error message!? 'Now is not
a recognized function name'.

How do I tell the SQL Server then to only return future events in 'pure
SQL code'?? I saw the solution somewhere once, but can't find it back ...

Any help is appreciated!

Jerome
 
E

el.c. - myLittleTools.net

could contain: SELECT * FROM table1 WHERE date1>=Now().

SELECT * FROM table1 WHERE date1>=GETDATE()
 
B

Bob Barrows [MVP]

Jerome said:
Hi,

Before I've queried my Access DB using ASP pages. The SQL string then
could contain: SELECT * FROM table1 WHERE date1>=Now().

This time round my DB is on a SQL Server and I'm still using ASP for
this. But now the Now() function returns an error message!? 'Now is
not a recognized function name'.
The equivalent T-SQL function is GETDATE()

SQL Books Online (usually referred to as BOL) is a great resource. If you've
installed the SQL Server client tools on your machine, it will be in the SQL
Server program group in your Windows Start menu.

It is available online at
http://msdn.microsoft.com/library/en-us/startsql/portal_7ap1.asp

And a downloadable version is available at:
http://www.microsoft.com/downloads/...b1-a420-445f-8a4b-bd77a7da194b&displaylang=en

Bob Barrows
 
A

Aaron [SQL Server MVP]

This time round my DB is on a SQL Server and I'm still using ASP for
this. But now the Now() function returns an error message!?

Well, yeah. SQL Server != Access! (Sorry, in Access, that would be, SQL
Server <> Access!) ;-)

Now() and GETDATE() and CURRENT_TIMESTAMP are covered here, which might make
for useful reading in general:
http://www.aspfaq.com/2214
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top