SQL: setting write to Date system

How to set a column in a table to accept only system date or more? What will be the sql query?

Sincerely.

+4
source share
3 answers

Today, the date corresponds to midnight today, so if you want to add dates from today, you also need something like

ColumnName >= select DATEADD(MILLISECOND, ((DATEPART(hh, GETDATE())*3600000)+(DATEPART(mi, GETDATE())*60000)+(DATEPART(s, GETDATE())*1000) +DATEPART(MILLISECOND,GETDATE()))*-1, GETDATE()) 
+2
source
 ALTER TABLE table1 ADD CONSTRAINT chk1 CHECK (date_column >= GETDATE ()) 
+2
source

Use Check Constraints :

 ColumnName >= getdate() 
+1
source

All Articles