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?
3 Answers
Alternatively in SQL Server you could use this simple comparison:
…
WHERE DateColumn >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0)
…
1 Comment
JNK
I +1'd from your original comment on my answer. Pretty large logical issue that you addressed.
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
Comments
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]
1 Comment
JNK
This isn't really an answer. This is like someone asking how to change the oil in their car and your response is "You just change it".