SQL Server Management Studio make default date 5 days from now

后端 未结 1 452
醉梦人生
醉梦人生 2021-01-28 05:21

I am working on a database and I need to make the default value for a date column to be 5 days from the current date.

Would using getdate() + 5 work?

相关标签:
1条回答
  • 2021-01-28 05:51

    Yout can tryout DateAdd function for adding days to date

    Example

    DATEADD(day,1,@datetimevar/column)
    

    try like this

    create table t(
      i int,
      d datetime default (dateadd(day,5,getdate()))
    )
    
    0 讨论(0)
提交回复
热议问题