sql - How can I use GETDATE() to get month and year from the past month? -
How can I get a statement that can get me last month and this year?
I enter one INSERT and one column report_date in [datetime]
table_A (report_data) values (??); I want to show this last month and year, for example today is 4/21/2014, so it will show 3/2014 in the column if today was May 1, 2014, Show 4 / 2014? Is it possible or should it be his day?
You are looking for function:
SELECT DATEPART ( Month, DATEADD (month, -1, GETDATE ()), DATEPART (year, DATEADD (month, -1, GETDATE ())
Comments
Post a Comment