I need a check constraint for date so no data can be entered after today's/this date.
please advise thanks all
Try this:
ALTER TABLE yourTable
ADD CONSTRAINT yourDateTimeColumn CHECK (yourDateTimeColumn < GetDate() );
To remove the time part on SQL Server 2008, use cast...date
Also, I assume you can have dates including today
ALTER TABLE yourTable
ADD CONSTRAINT yourDateTimeColumn CHECK (
CAST(yourDateTimeColumn as date) <= CAST(GETDATE() as date)
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With