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

date checking in a single select statement 1

Status
Not open for further replies.

joereena

Programmer
Apr 18, 2001
8
0
0
IN
Hi,

I want to see whether a given date is equal to, greater than or less than sysdate. How can I do it using a single select statement.

Please Help.
Thanx in advance.
 
I will try:
select to_date(given_date) from your_table
where to_date(given_date,'mm/dd/yyyy') < to_char(sysdate,'mm/dd/yyyy')
or to_date(given_date,'mm/dd/yyyy') = to_char(sysdate,'mm/dd/yyyy')
or to_date(given_date,'mm/dd/yyyy') > to_char(sysdate,'mm/dd/yyyy');
or you can test them individually by testing for:
to_date(given_date,'mm/dd/yyyy') < to_char(sysdate,'mm/dd/yyyy') first

and to_date(given_date,'mm/dd/yyyy') = to_char(sysdate,'mm/dd/yyyy') second
or to_date(given_date,'mm/dd/yyyy') > to_char(sysdate,'mm/dd/yyyy') third
or any combination.
 
joereena,

How do you want to show it? In an message box as the date is being saved? or in a different field?

Chester
 
If your field is of DATE datatype you may

select decode(sign(your_date_field - sysdate), 1, 'MORE'
, -1, 'LESS', 0, 'EQUALS', 'UNDEFINED') from dual

If it's of some character datatype you may use the same making conversions with to_date().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top