I have a sales report of SSRS, which I need to pass dates for the preliminary date and expiry date of the previous month I, however, to use the code given below, since the sales report has figures for the previous year (2014) I have to pass the dates of the previous year too. The code given below gives the start date 1 2015-02-01 and the end date 1 2015-02-28 as the date for the previous year 2014-02-01 like the start date 2 and 2014-02-28 as the Endadet 2 Required to receive
SELECT DATEADD (MONTH, DATEDIFF (MONTH, '19000201', GETDATE, '19010101') AS StartDate1, DATEADD (MONTH, DATEDIFF (MONTH, '19000101 ', GETDATE ()),' 18991231 'AS EndDate1
Since the last day of the month May be different, so the important thing is that the current year The first day is to achieve this year, with that you can calculate the other three values.
You can do this easily with expressions in the basic values of the parameter instead.
start of month = today. 1- today. Day) end of month = today. Extra days (1- today). Add (1). Add days -1) Last year ending month: = Today. Add days (1- today). Add the year (-1). Add (1) .day (-1)
But if you really want to do it in SQL, you can. The notes given below tell me how to get the beginning of the month and then for clarity, in other manifestations, using only the placeholder variables.
These are the pieces as soon as you can read the selection statement in a huge, put together:
selecting the date (Month, 0, meet ()), 0) start date 1, datead (day, -1, datead (month, 1, date (month, dated (month, 0, meeting ()), 0) ) 0)) 0)) 0)) 0)) 0)) Date of birth 2, dateaid (date), date (date, date, date, date, date, date (month, month, date) Day, -1, Date Added (year, -1, date of the year (year, -1, date of the date (month, dated date) code>
Now you see why I only use internal parameters Tax Confirms that those who can take advantage of .NET datetime class methods.
No comments:
Post a Comment