AK SQL AK SQL - 7 months ago 14
SQL Question

inserting current date values into columns

can u insert current date via function in an insert statement something like this

insert into table name
values
(getdate(), getdate()-1)
,(getdate(), getdate()-1)


the above example may be vague but can this concept be done.

Answer

Yes you can manipulate function directly

SELECT GETDATE()-1

But I will Suggets use DATEADD function

SELECT DATEADD(D,-1,GETDATE())