Now() function in SQL??

  • Thread starter Thread starter Jerome
  • Start date Start date
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
 
could contain: SELECT * FROM table1 WHERE date1>=Now().

SELECT * FROM table1 WHERE date1>=GETDATE()
 
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
 
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
 
Back
Top