Home » SQL & PL/SQL » SQL & PL/SQL » Compare dates
Compare dates [message #36473] Thu, 29 November 2001 05:12 Go to next message
Sheryl
Messages: 6
Registered: November 2001
Junior Member
Hi!
I have two columns of type date:
Valid_From Date
Valid_To Date
I want to make the check that 'Valid_From' Date is always earlier (before) 'Valid_To' Date.
How should I make that comparison;
Thnak you a a lot in advance.
Sheryl

----------------------------------------------------------------------
Re: Compare dates [message #36474 is a reply to message #36473] Thu, 29 November 2001 05:46 Go to previous messageGo to next message
Dan
Messages: 61
Registered: February 2000
Member
IF VALID_FROM > VALID_TO
RETURN ERROR STATMENT
END IF;

----------------------------------------------------------------------
Re: Compare dates [message #36481 is a reply to message #36474] Thu, 29 November 2001 07:15 Go to previous message
Rob Baillie
Messages: 33
Registered: November 2001
Member
Although I notice you asked for 'valid_from before valid_to' which would be

IF Valid_From >= Valid_To

Note that these also work for open ended (I.E. Valid_to is left NULL), since comparison to NULL (with anything other than 'IS NULL') will always fail.

----------------------------------------------------------------------
Previous Topic: Re: Mutating Trigger...More thoughts
Next Topic: Re: Mutating Trigger...More thoughts
Goto Forum:
  


Current Time: Sun Mar 29 23:37:06 CDT 2020