How can I get a date 60 months ago?

2

I want to pick up some date 60 months ago.

I'm in a project that shows only files Sent to 60 months, but 60 months rather than 5 years, may not make any difference.

Any ideas? I tried to use datediff, but I'm not successful. I want to do this in SQL procedure

SELECT CAST(DATEPART(YY, GETDATE()) - 5  AS VARCHAR)

Note that the "5" before varchar refers to 60 months or 5 years; however, it wants 60 months. How could I get this date 60 months ago.

    
asked by anonymous 10.09.2014 / 12:43

1 answer

10

In your query, you should use DATEADD

SELECT GETDATE() AS Hoje, DATEADD(M, -60, GETDATE()) AS [60MesesAtras]

Since you did not provide more details in your question, this is the most I can help you with.

SQLFiddle Example

    
10.09.2014 / 13:18