Constrain Partial Values in Timestamp

constraintoracletimestamp

I'm working on a some Create Table statements for a project I have. I have two columns (StartDate, EndDate) where the data type is Timestamp. One of the requirements is to ensure that the date is fixed (January 1, 2000) but leave the time variable. How would I go about including that in my Create Table statement?

Best Answer

Try something like

CREATE TABLE test_stmp(StartDate TIMESTAMP NOT NULL,
constraint chk_test_filed check(trunc(StartDate) = to_date('2000-01-01','yyyy-mm-dd')));