10 pts.
 SQL (Oracle) Date Constraints
Can someone tell me how to create a constraint to prevent entering a date prior to 1 Jan 2007? I am tryin g to do it in a create script. Thanks Lock

Software/Hardware used:
ASKED: March 12, 2008  1:00 AM
UPDATED: March 12, 2008  12:32 PM

Answer Wiki:
Hi , You can use check constraint on column which will check date is grater than 1 jan 2007 or you can create trigger before insert or update which will check that date is grater than 1 jan 2007 . easy way to use check constraint on column below is example CREATE TABLE test ( log_date DATE CHECK(log_date > to_date('01/01/2007' , 'dd/mm/yyyy')) ) if table already exists then use ALTER TABLE test ADD CONSTRAINT con_chk CHECK(log_date > to_date('01/01/2007' , 'dd/mm/yyyy')) but for this command to run there should not be single row having date less than 1 jan 2007
Last Wiki Answer Submitted:  March 12, 2008  4:38 am  by  BlueStar   90 pts.
All Answer Wiki Contributors:  BlueStar   90 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

It should be a simple date comparison…
…. where date > ’1/1/2007′

The only tag you have is SQL (oracle) Date Constraints. Do you want this as a SQl statement or someother language, like vbscript.

Be sure and check out my blog here on ITKE for more Network administration and VBSCRIPT tips.
The VBScript Network and Systems Administrator’s Cafe

 5,320 pts.