Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SYSDATE system variable?

Status
Not open for further replies.

NutsMonkey

Programmer
Sep 20, 2004
2
0
0
GB
Hi, I'm trying to write a query for a report which will ignore recent transactions. I would like to therefore put in the WHERE clause of the SQL query something of the form:

AND OrderDate < ( SYSDATE - 60 )

I have no idea how to express SYSDATE in SQL server syntax. Can anybody help?

Is there a system date standard system variable for querying in the SQL Server environment.

Thanks in Advance
 
GetDate() is the function you are looking for.

Sample Code:

Code:
orderdate <  dateadd(day, -60, convert(varchar, getdate(), 101))

Regards,
AA
 
Try:

AND OrderDate < (SELECT DATEADD(day, -60, GETDATE()))


GETDATE() is the system function that returns current date.

Use DATEADD for the date arithmetic....second, minute, hour, day, week, month, year etc are all valid for the 1st parameter.

hth,
Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top