SQL query for today's date minus two months

前端 未结 5 1266
天命终不由人
天命终不由人 2020-12-12 15:40

I want to select all the records in a table where their date of entry is older then 2 months.

Any idea how I can do that?

I haven\'t tried anything yet but I

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 16:27

    If you are using SQL Server try this:

    SELECT * FROM MyTable
    WHERE MyDate < DATEADD(month, -2, GETDATE())
    

    Based on your update it would be:

    SELECT * FROM FB WHERE Dte <  DATEADD(month, -2, GETDATE())
    

提交回复
热议问题