SQL server - Select all items with a date on the previous month -


I have a table in my SQL Server database that is called " item " whose column " Done ".

I have a script that will run on the first day of every month, which will have to select all the items that end in the previous month.

Therefore, for example, on February 1, all the items must be selected where dated is between 1 January to 00:00 or less and less than 00:00 on 1st February.

It also needs to work in new years (such as DEC - Jane).

Any thoughts?

You have a date code of the last month of the dateadd (m, -1, getdate ()) Can be found with . After that, filter the year and month of that date, in which where in the section, such as:

  select where datepart (yy, dateFinished) = datepart ( Yy, datayed (m, -1, millennate ()) and dataparte (m, datinfinished) = deterterate (m, datayed (m, -1, dddet ()))  

Work throughout the year, and if the question is run in later days than in the next month.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -