Reputation: 2388
I want to show data from the last month (not form months past though), this month and any futures data in my report. In a SQL view, how can you do this with the date fields called date?
Upvotes: 0
Views: 209
Reputation: 77657
Alternatively in SQL Server you could use this simple comparison:
…
WHERE DateColumn >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0)
…
Upvotes: 2
Reputation: 10327
I'm assuming you are using SQL Server, in which case use the DATEDIFF
function to see if the date in your table is within the range you want to display.
Information on the function can be found here: http://msdn.microsoft.com/en-us/library/ms189794.aspx
Upvotes: 1
Reputation: 2244
there is a built in function in SQL Server to add the date .. and for your date field named as date select it as [date]
Upvotes: -1