1

Can you insert current date via a function with an insert statement?

Should look 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?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
AK SQL
  • 57
  • 6

2 Answers2

1

In a word - yes. You can use the results of function calls or calculations as arguments to a values clause of an insert statement.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
1

Yes you can manipulate function directly

SELECT GETDATE()-1

But I will Suggets use DATEADD function

SELECT DATEADD(D,-1,GETDATE())
Jaydip Jadhav
  • 12,179
  • 6
  • 24
  • 40