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

Using sysdate as a paramter

Status
Not open for further replies.
Oct 12, 2005
204
GB
Hi,

I'm new to Oracle / plsql I'm trying to find a way to write a simple query but use sysdate as a default parameter, but this parameter can be changed by the user if necessary.

Thanks,

Mick.
 
use a DEFINE VARIABLE

select count(*)
from so
where so_wr_dt > nvl(to_date('&my_date','MM/DD/YYYY'),TRUNC(SYSDATE))
SQL> /
Enter value for my_date:
old 3: where so_wr_dt > nvl(to_date('&my_date','MM/DD/YYYY'),TRUNC(SYSDATE))
new 3: where so_wr_dt > nvl(to_date('','MM/DD/YYYY'),TRUNC(SYSDATE))

COUNT(*)
----------
0

SQL> /
Enter value for my_date: 02/01/2018
old 3: where so_wr_dt > nvl(to_date('&my_date','MM/DD/YYYY'),TRUNC(SYSDATE))
new 3: where so_wr_dt > nvl(to_date('02/01/2018','MM/DD/YYYY'),TRUNC(SYSDATE))

COUNT(*)
----------
758703

Bill
Lead Application Developer
New York State, USA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top