Has any one been able to use the CURRENT_DATE function?
I'm in the middle of a very simple SQL query, and I keep
getting errors when I try and use CURRENT_DATE. Here is
my SQL QUERY:
Select * from Cal where ONDATE >= (CURRENT_DATE - 3)
Sounds simple enough but it always returns "Syntax Error
near 'CURRENT_DATE' I can't see any syntax error in the
above statement.
I'm running SQL server 2000
Use either GETDATE() or CURRENT_TIMESTAMP and convert if you just want the
date part.
You need to escape calls to CURRENT_DATE e.g
select {fn CURRENT_DATE()}
Note this returns a varchar so you need to convert to datetime
select * from orders where OrderDate < (cast({fn CURRENT_DATE()} as
datetime)-3)
HTH
Jasper Smith (SQL Server MVP)
http://www.sqldbatips.com
I support PASS - the definitive, global
community for SQL Server professionals -
http://www.sqlpass.org
"Pierre" <pmitham@.pbviews.com> wrote in message
news:085001c48479$1871ffd0$a301280a@.phx.gbl...
> Has any one been able to use the CURRENT_DATE function?
> I'm in the middle of a very simple SQL query, and I keep
> getting errors when I try and use CURRENT_DATE. Here is
> my SQL QUERY:
> Select * from Cal where ONDATE >= (CURRENT_DATE - 3)
> Sounds simple enough but it always returns "Syntax Error
> near 'CURRENT_DATE' I can't see any syntax error in the
> above statement.
> I'm running SQL server 2000
|||Wonderfuil. But that's a bit different from what MS says
the Syntax is ;-) figures.
>--Original Message--
>Use either GETDATE() or CURRENT_TIMESTAMP and convert if
you just want the
>date part.
>You need to escape calls to CURRENT_DATE e.g
>select {fn CURRENT_DATE()}
>Note this returns a varchar so you need to convert to
datetime
>select * from orders where OrderDate < (cast({fn
CURRENT_DATE()} as[vbcol=seagreen]
>datetime)-3)
>--
>HTH
>Jasper Smith (SQL Server MVP)
>http://www.sqldbatips.com
>I support PASS - the definitive, global
>community for SQL Server professionals -
>http://www.sqlpass.org
>"Pierre" <pmitham@.pbviews.com> wrote in message
>news:085001c48479$1871ffd0$a301280a@.phx.gbl...
keep
>
>.
>
|||If you can post to where MS documents the syntax you tried, we can feedback to them...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Pierre mitham" <pmitham@.pbviews.com> wrote in message
news:7e1101c48495$be2ab540$a401280a@.phx.gbl...[vbcol=seagreen]
> Wonderfuil. But that's a bit different from what MS says
> the Syntax is ;-) figures.
>
> you just want the
> datetime
> CURRENT_DATE()} as
> keep
Thursday, March 22, 2012
Current_Date function
Labels:
current_date,
database,
errors,
function,
functionim,
keepgetting,
microsoft,
mysql,
oracle,
query,
server,
sql
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment