So i am going to be upgrading some scheduler code and it is currently very dumb. I would love to upgrade the code to be similar to Outlook's every Monday at 5 etc. or every third Thursday of the month.
Current schedule system can not specify a day of the week only a period like (daily, weekly, monthly, annually) and can not specify time, or a specific day, like weekly is only on Friday. and the daily is only at 7 am. (so weekly would be Friday at 7 am)
Are there any resources that I can look up to understand how this would work?
My Google searches so far have turned up nothing useful, due to using the word outlook.
Boost.Date_Time should give you the date manipulation functions you need. Should be easier to use their (debugged) code rather than trying to reinvent it.
Related
If someone could please advise on how to achieve the following function on my site: I have a business where I ship live animals to customers. The challenge is communicating the weather forecast with the customer, along with the safest day/s to ship for the animals’ wellbeing. This planning is especially key during the peak summer and winter months when temperatures are very extreme. I am looking to automate these functions during the customers checkout process, giving them control of the shipping date. I am looking to implement something like this on my site.
I found another website where I recently placed an order that provided this relevant information for the customer to review before deciding on what day they would like to have the animal shipment shipped out. The table provided a 5 day forecast, which included temperatures for morning and evening at the point of origin, in transit, as well as the customers’ destination address. Any day/s where the temperature is too hot or too cold was marked as unavailable (red) for shipping. Possible shipping dates consisted of two consecutive days where temps are in the safe range and labeled as available (green) Excluding Friday, Saturday, and Sunday. It is also important for the customer to plan ahead and pick a shipping day based on their availability to be home to receive the package the following morning.
I would like to create a perpetual calendar in Power BI (Power Query) with the holidays. The thing is, I live in Canada and Easter and Victoria Day are quite complicated to integrate in this kind of calendar.
For the perpetual calendar, I used this technique (you can find the code on this website), which is very effective. It's "simply" a function to which you tell that you want a calendar from this date to this date and it generates everything you want and probably more. However, the calendar doesn't know which day is a holiday. So you need to have another request in Power BI with all the holidays for that period. Then you tell the calendar to use this holiday request as a reference point and then it will know which day is a holiday.
This is where it gets very complicated. Some holidays are based on a specific date, some are based on a specific day and others vary a lot.
Based on a specific date : New Year's Day, January 1st ; Saint-Jean-Baptiste Day, June 24 ; Canada Day, July 1st ; National Day for Thruth and Reconciliation, September 30 ; Remembrance Day, November 11 ; Christmas Day, December 25 ; Boxing Day, December 26.
Based on a specific day : Labour day, first Monday of September ; Thanksgiving, second Monday of October.
Those that vary a lot : Good Friday, Friday before Easter ; Easter, first Sunday after the Paschal full moon ; Easter Monday, Monday after Easter ; Victoria Day, last Monday preceding May 25.
Finally, some holidays happen only once to commemorate specific events like the death of the Queen on September 19, 2022.
I would like to create a function to which I indicate that I want all holiday for a specific period and it generates everything by itself. Then I could tell my calendar function to use it as a reference to know which day is a holiday. It would also be great if I could add some new holiday here and there for specific events like the death of the Queen.
For holidays like New Year's Day, Canada Day and Thanksgiving, I used this tutorial, but it's incomplete. Also, it doesn’t explain how to integrate holidays like Easter or Victoria Day. So this is where I'm stuck right now.
I know it's complicated but if someone can help me, it would be awesome.
As Jon suggest, I think it will be a lot easier to use the canada-holidays.ca/api.
I'm having issues with this API though. If I want multiple years in a single request, I need to create a request for each year and then append them. I'm trying to find a way to only have a single request but I'm struggling with this as well.
As soon as I find a solution, I'll update this post.
EDIT
Someone help me with that on another post. You can find the solution right here!
I have a strategy that calculates entry/exit criteria based on Daily timeframe, but I use 15min timeframe to actually trade against those daily values. It works fine, EXCEPT when I try to go farther back in time to backtest than the current 15min chart will show.
As a simple example, is there a way in Pinescript to:
Calculate EMA 20 cross above EMA 200 on a DAILY timeframe
Backtest trades that on a 15min timeframe go long when this occurs or short during the opposite.
I can make that work, but I cannot for example go back to Jan 1, 2014 to June 1, 2014 15-min historical data and backtest the same criteria as Tradingview just resets the timeframe to Weekly to be able to show that far back.
Any ideas are greatly appreciated as I currently do things in excel and it takes a while per symbol.
Thanks
I'm trying to find latest Sunday (just for the sake of the example)
In the link below I have found an explanation how to use a date function called date_part to extract the day of week (for example, for current timestamp) and other parts of the date which might be interesting.
https://docs.aws.amazon.com/redshift/latest/dg/r_DATE_PART_function.html
The gist of it:
for example to find day of week
select date_part(dow, starttime) as dow
from event
But when I try to run something similar on Athena I receive "function date_part not registered".
So how can I find the latest Sunday? Or any other day of the week for that matter.
You can combine current_date with day_of_week to get the last Sunday:
presto:default> SELECT date_add('DAY', -day_of_week(current_date), current_date);
_col0
------------
2019-12-15
(1 row)
Note: when it's run on Sunday, this returns previous Sunday. You can easily adjust this as needed with if.
Tested on Presto 326.
As Athena is currently based on Presto .172, this is where you can learn about all available functions: https://trino.io/docs/0.172/functions.html
AWS Athena uses Presto so you need to use the Presto date/time functions. (Redshift, on the other hand, seems to be loosely based on PostgreSQL.)
To get the latest Sunday, you should use day_of_week() to find Sundays, and you can restrict your query to dates in the last week to limit it to the most recent Sunday.
To find the latest sunday you can use:
select DATE_ADD('day', -(extract(dow from (datecolumn + interval '1'day))-1),cast(day as date))
Since athena considers first day of week as monday and last day of week as sunday, but in your case we want to consider first day of week as sunday, So, I have used interval '1' day to make sunday shift and consider as the first day of week.
I am looking into utilising PowerBI to identify time saved due to various Projects. People will add the projects to a Sharepoint List which then feeds into PowerBI.
PROJECTs Table:
Project Tite, Desc, Hours/Month Saved, StartDate, EndDate, Repeat? (T/F)
[Some Projects only save a fixed 10 or so hours, others save time per month (indicated by the Repeat Column)]
I've created two measures, RUNTIME determining how long the project has run in months ((TodayDate - StartDate)/30) as well as TIMESAVED which is the total hours saved from that specific project (RUNTIME*Hours/Month Saved).
Whilst this works, it has a pretty big limitation. When selecting a range, say 01/01/2017 - 01/01/2018, any projects with a start date before that range are excluded. However these maybe on-going, meaning the time saved by this project during the range needs to be added.
I've attempted to find a solution to this, however I keep getting stuck at requiring the the filter dates from the slicer, however I'm not certain this is possible. I need those projects with on-going savings to have the savings during the period given to be counted as well.
Possible alternative maybe to create a Month/Year column per Month/Year with a custom formula per column to determine that projects Hours saved for that Month/Year however this seems inefficient, at that point back to Excel might be better.
Any ideas / suggestions would be greatly appreciated, currently running through any ideas to solve but keeps coming back to needing that value specified by the filter. Cheers in advance for any advice tackling this :)
See also: https://community.powerbi.com/t5/Desktop/Re-occuring-Savings-over-Time-with-Time-Date-Slicer/m-p/346100
Unfortunately, there is no current simple solution to this problem out-of-the-box with Power Bi. All of the slicers seem to handle dates as a single point in time. They suffer in that if you are dealing with any items that span a Start and End date (like your projects, and most of my data examples) they only take one of the dates as the input. The slicers need to accept an optional end date in our case and then perform a simple date span overlap logic to determine the items that match.
I tried to solve your problem with out-of-the-box Power Bi Desktop slicers and a custom visual Timeline Slicer I found at the store with no luck earlier this month. Out of frustration, I posted a question in the Power Bi forums for suggestions.
The final suggestion from the forums I got was to "use two Filters at Filter pane". But I am not satisfied with this answer.
The Timeline Slicer code is open source and when I get more time (ha ha), I would like to make this change to the Timeline Slicer and publish it back to the repository for everyone to use.
I will monitor this question and the forum to see if a solution emerges in the future.
You can use Timeline Storyteller. you can create your time line and add a couple Slicers for Start and End. It will split by day the dates and you won't miss any data.