How to display a recurrence meeting for all recurrence days - sql

enter image description hereI want to display a recurrence meeting in a list using a SQL.
Table: Events
Attributes: EventId, EventName, EventStart datetime, Event End datetime, EventType
Expected Output
Event: Daily scrum
Date: 3rd Dec 2022, 10am
Event: Daily scrum
Date: 4th Dec 2022, 10am
Event: Daily scrum
Date: 5th Dec 2022, 10am
Event: Daily scrum
Date: 6th Dec 2022, 10am
Event: Daily scrum
Date: 7th Dec 2022, 10am
can someone help me to achieve this in SQL?

Related

Weeks rolling up to months in SQL (date_trunc)

I am working on a MODE Case Study which can be accessed here https://mode.com/sql-tutorial/a-drop-in-user-engagement/#the-problem.
I am trying to access Table 2: Events which has a date column 'occurred_at'. I wanted to check the time frame of this case study, that is weeks and months.
I wrote a simple query
select distinct(date_trunc('week', occurred_at)) as week, date_trunc('month', occurred_at) as month
from tutorial.yammer_events
where event_type = 'engagement'
order by week;
and to my surprise, the first week of '2014-04-28' showed the month 'May' instead of 'April.
Can someone please tell me what is the reason for this?
Thank you
The PostgreSQL date_trunc rolls up the date to the first instance of the date depending upon the granularity (day, week, month, etc.)
For month this instance is the first day of month i.e. Day 1.
For week this instance is the first day of week i.e. Monday.
Suppose the date is 4th July 2021 which is Sunday, then the date_trunc will result in 1st July 2021 for month and 28th June 2021 for week which is Monday inside that week.
Suppose the date is 5th July 2021 which is Monday itself, then the date_trunc will still result in 1st July 2021 for month but result in 5th July 2021 for week since it is already Monday.

ToDate paramenter not showing the current date records in SSRS report

I am using FromDate and ToDate parameter to filter the records in SSRS report. If I choose from date as 1st Oct 2020 and Todate as 15th Oct 2020, then it is showing the records till 14th Oct 2020 even though I have data for 15th Oct 2020.
The query looks like below and really appreciate your support.
SELECT * FROM table1
WHERE to_date(created_date) >= '2020-10-01'
AND to_date(created_date) <= '2020-10-15'
Thank you.
Regards,
Viresh

Find last 10 business days of the current month for schedule

I have a couple of scenarios
Scheduler should compare the current day is with in the last 10 business days of the current month then it should schedule to run current day with 11AM CST.
(E-g) current day : 18th July 2017 (with in last 10 business days) should run and reschedule at 19th July 2017 11.AM CST
IF Last business day(30th or 31st) after runs the scheduler should reschedule it to next month.
(E-g )current day : 31th July 2017 (with in last 10 business days) should run and reschedule at 18th Aug2017 11.AM CST
Can any one help to derive the logic in oracle 11g scheduler?
Thanks in Advance.

Max Nested Level SQL Server - Create Calendar type table

I currently have a table which holds rate periods for services. These periods need to be created in the following way based on a provided start date and end date
If start date is not the start of a week, a record must be inserted
from the Start date until the end of the week containing the start
date.
The next record to be inserted will be the start of the week after the start date up until the end date of the last full date prior to the end date (it can be up until the end date, if the end date is a last day of the week.
There is also a requirement to add individual records for bank holidays
The table is currently populated using recursive stored procedures,but has been failing recently due to exceeding the max nest level for SP', functions etc.
I want to remove this issue and I have no issues creating the table where there are no bank holidays, but I am having problems dealing with the bank holiday insertion and update of previous rates entered.
For example take the following
Start Date: 5th Jan 2017
End Date: 8th April 2017
Last Day of Week: Sunday
Bank Holidays: Mar 9th and Apr 6th
The returned records should be
5th Jan - 8th Jan (5th is not a Monday)
9th Jan - 5th Mar (End week prior to Bank Holiday)
6th Mar - 8th Mar (part week due to Bank Holiday)
9th Mar - 9th Mar (Bank Holiday)
10th Mar - 12th Mar (Part week due to Bank Holiday)
13th Mar - 2nd Apr (Full weeks)
3rd Apr - 5th Apr (Part week due to Bank Holiday)
6th Apr - 6th Apr (Bank Holiday)
7th Apr - 8th Apr (End of Period)
I have looked into using recursive CTE's to do this but I am having issues with this.
Any ideas on the best way to implement the above?

How do I programmatically generate a dataset in a SSRS report?

I want to execute a SQL query and use the results of that query to generate my own dataset for use in a SSRS report.
More specifically, I'm trying to create a SSRS report subscription calendar. The calendar will display when certain subscriptions are scheduled to run.
I plan to do this by querying the report server's schedule table and generating a row for each scheduled run.
e.g. Subscription A runs every weekday at 2pm. Subscription B runs every Monday at 9am.
This is the dataset I want to generate for some arbitrary week:
Monday Sep 14, 9:00:00, Subscription B
Monday Sep 14, 14:00:00, Subscription A
Tuesday Sep 15, 14:00:00, Subscription A
Wednesday Sep 16, 14:00:00, Subscription A
Thursday Sep 17, 14:00:00, Subscription A
Friday Sep 18, 14:00:00, Subscription A
Is this possible?
Is the following article useful regarding querying the report server the reports are hosted on/in
Query SSRS Report Schedules