Reputation: 1183
I need to add a constraint that time entered in a column is only after 8:00 am. I've tried
alter table toy_store ADD CHECK (store_opening_time > TIMESTAMP '2013-05-05 08:00:00');
This only allows entry of timestamp greater than 5th May 8:00 am. I want to write a query that checks if the entry is after 8:00 am notwithstanding the date.
Upvotes: 1
Views: 11199
Reputation: 361
you can do it like this :
alter table toy_store ADD CHECK (EXTRACT(HOUR FROM store_opening_time) > 8 || NULL);
Upvotes: 1