Reporting Services Quarterly Schedule instead running Monthly - reporting-services

I have a report in SSRS 2012 scheduled to run quarterly on a specific day i.e. 15th Jan, 15th Apr, 15th Jul & 15th Oct.
My shared schedule config is: Ticked 'Month', selected Jan, Apr, Jul & Oct, set 'On calendar day(s)' to '15'.
The schedule is displayed correctly but in fact runs on the 15th of each month.
Knowing these schedules are actually implemented using SQL Server Agent I inspect the job and find that the job in question has 4 schedules against it.
15th day of every 12 month starting on the 1 jan 2013
15th day of every 12 month starting on the 1 apr 2013
15th day of every 12 month starting on the 1 jul 2013
15th day of every 12 month starting on the 1 oct 2013
so that also makes sense.
Is there a fix to this issue?

I think the problem (and solution) is the same as described here https://techcommunity.microsoft.com/t5/System-Center-Blog/Support-Tip-Scheduled-backup-to-tape-runs-on-a-wrong-date-on-DPM/ba-p/347075

Related

MySQL query. Creating a table displaying information by month and week

please tell me how the query should be compiled for the table with the following lines: January 2019, first week of January 2019, second week of January 2019 ... fifth week of January 2019, February 2019, first week of February, 2019 second week of February 2019 .... Fifth week of December 2019. The amount of goods sold will be displayed in columns. That is, in the line of the month - the number of sales for the whole month, in the line of the week - the number of sold only for this week.

MySQL get date of last month

I have this script which is run on the 15th of every month. This script intends to automatically take the last date of the previous month in the format of 'YYYY-MM-DD'. Is there a sql statement to do that?
For example today is 15th January 2017. I will run my script and it will give me a date of 31th December 2016 in the format 2016-12-31.
If it is 15th December 2016, I will get 30th November 2016 in the format 2016-11-30.
Thank you
You can use curdate() - interval 1 month paired with last_day =)
select last_day(curdate() - interval 1 month) as 'last_day_last_month';

MySQL Custom WEEK() Mode

I am trying to create a weekly report (including grouping by WEEK(date)) where weeks start on Monday. However, Week 1 is always the first week any day of a new year occurs. For example if Jan 1st is a Friday, that is week one.
This doesn't seem to be consistent with MySQL mode options for WEEK():
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_week
Based on the available options it only works if the week has 4 or more days (options 1 and 3) or the Monday is in the new year (options 5 and 7). Neither of these account for example week 1 of 2016:
Wk Mon Tue Wed Thu Fri Sat Sun
No.
1 28 29 30 31 1 2 3
Is there any way to order/number the week numbers in MySQL based on this custom week mode requirement?

Time Cycle issue in SQL Quires.

In my rails application currently have opening and closing schedules in the application for every restaurant. Like
Monday 5:00 AM to 11:45 PM
Tuesday 6:00 AM to 11:00 PM
Wednesday 9:00 AM to 8:00 PM
Thursday 11:00 AM to 11:45 PM
Friday 5:00 AM to 11:45 PM
Saturday 5:00 AM to 11:45 PM
I have saved the above time into the database with 24hour database time format. It is working perfectly fine. as when i try to get information about the open restaurant time due to 24 hours time i am able to query the data from the database. But now my client wants that the closing time can be 2:00 AM, 2:30 AM as restaurant closes definitely after the mid night.
How it is possible to manage in the SQL Quires? How can i check for a specified period of a time restaurant is open or not?
Currently I have the following Query being executed:
SELECT
COUNT(*)
FROM
`sechedules`
WHERE
`sechedules`.`sechedulable_id` = 16
AND `sechedules`.`sechedulable_type` = 'Operation'
AND (day = 'Wednesday')
AND (opening_time <= '21:28:23'
and closing_time >= '02:28:23'
and is_closed = 0);
I can change the cycle of the day. It can start from the 5:00 AM to 4:59 AM. But how to manage in the database comparisons I'm not getting the best possible solution.
I suggest you formulate your queries around start-time and duration. You could do this from your present dataset. This query gets start time and duration from your table.
select weekday,
start,
stop,
timediff(
if (TIMESTAMPDIFF(MINUTE,start,stop)<0,stop+INTERVAL 24 HOUR, stop),
start) duration
from sechedules
As you can see, it does some monkey business to add 24 hours to the closing time if it shows up as earlier than the opening time.
Then, you can check how many records match a particular time of day like this.
select count(*) cnt
where sechedulable_id = 16
and day = 'Wednesday'
and start <= '21:28:23'
and '21:28:23' <= if(TIMESTAMPDIFF(MINUTE,start,stop)<0,stop+INTERVAL 24 HOUR, stop)

SSRS Report with Business days as Expression

I have an SSRS report with the following header,
Date 28-Mar 27-Mar 25-Mar 24-Mar 23-Mar 22-Mar 21-Mar 20-Mar
Day Fri Thu Wed Tue Mon Sun Sat Fri
Pending 1 2 3 4 5 5 5 6
I able to generate Date and Day rows using expression with current date.
(e.g. = Left(WeekDayName(WeekDay(DateAdd("d",-1,Now()))),3))
But Pending Days row should display age in days with same age number for Mon, Sun and Sat since Sun and Sat are off days.
Is it possible to generate with expression?
Got it Guys,
We just need to make sum of no of 'mon', 'tus'..'fir' in the date range.
=DATEDIFF("ww",DateAdd("d",-1,Now()),Now(), vbMonday)
+
DATEDIFF("ww",DateAdd("d",-1,Now()),Now(), vbTuesday)
etc.
:)