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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Current date in sql script

Status
Not open for further replies.

Benouche

Programmer
Aug 6, 2002
48
FR
Hello,

Is there any way to get the current date (in date format if possible ...) in a sql script. Could come from any sure place (DB, Server ...)

I need this for filtering datas !

Thanks a lot,

Benouche [pipe]
 
Depends on your database.

For example in sql server it is

select getdate()

 
And in standard SQL it would be CURRENT_DATE like in:

1. select id, name
from table
where reg_date = current_date;

2. select id
from table
where regdate > current_date - interval '20' day(5);
 
In Oracle its sysdate, like in

select *
from transactions
where transdate > sysdate - 7;

gets all transactions for the last seven days.
 
Hi PetersJazz,

If i write the command sysdate in sqlplus, I get an error msg 'Unknown command'

In the same time I was looking for it on Internet and I get the same answer > sysdate

I get confused ... Any idea ?

 
ok thanks everybody, Jazzateers and others,

I understood finally .. I'm new to dbs.... [sadeyes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top