How to handle recurring holidays in Salesforce - salesforce

In salesforce I can create recurring holidays and based on that in my apex class I want to check whether the current day is holiday or not.
This works fine with normal non recurring holiday. But when I create recurring holiday there is no way to find whether current date will fall on any of the recurring dates.
the holiday object's ActivityDate returns the start date of holiday.
Does anyone have checked the recurring holidays in past for salesforce?

Here is how i would approach this.
Create a function that will take parameters like RECURRENCESTARTDATE , RECURRENCEENDDATEONLY, RECURRENCETYPE, RECURRENCEINTERVAL, RECURRENCEDAYOFWEEKMASK, RECURRENCEDAYOFMONTH, RECURRENCEINSTANCE, RECURRENCEMONTHOFYEAR.
Then this function will loop from start date and for ever iteration it will increment value till date is > today or date is > RECURRENCEENDDATEONLY
in this loop you can check if today's == date calculated above.
once this function is ready pull out list of all recurring holidays.
and call above function on each list item.
let me know if you have any questions.

Related

RRule Repeating monthly calendar event on weekday only

I have an recurring event on the 7th of each month but am struggling to find an RRule that I can put into a text editor and import into google calendar. I need the rule to put the event on the last week day if the 7th falls on a weekend. Thanks in advance.
Due to the fallback condition, I don't think you can achieve this only defining a RRULE, unfortunately.
RRULE in Google Calendar follows RFC 5545 specification.
With RFC 5545, regarding monthly recurrences, you can either set the recurring rule for a specific day of the month (e.g. always on the 7th of the month would be RRULE:FREQ=MONTHLY;BYMONTHDAY=7) or a specific offset of day of the week within a month (e.g. second to last weekday of the month would be RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2).
Only using this specification, I don't believe there is a way to select the previous (or next) weekday in reference to the 7th day of the month.
However you can always achieve this by using a script to generate the dates or interpret an existing list you already have before insert them on Google Calendar.

Search between two dates with ISO8601 format

Using angularjs, dynamodb as DB here.
I have a form where user saves some data. I save my "CreateOn" date in my dynamo db as:
DateTime.UtcNow.ToString("o");
//This saves date in DB as:2018-08-21T12:58:08.7823906Z
Storing like this because dynamo db requires dates (string) to stored in ISO8601 format if you want to use between operator to search for date range.
Now I have a search filters on my page which is basically an angular calendar. When the user selects the date in the calendar( start and end date) I want to get the data back based on the selected date. Here I am using moment to pass the calendar selected date to my api call as:
moment(createdOn).toISOString()
Eg: If they select the Today's date in the calendar I pass the selected date
(Tue Aug 21 2018 00:00:00 GMT-0400 (Eastern Daylight Time)) to the above function
The result of passing this date to moment(createdOn).toISOString() is
2018-08-21T04:00:00.000Z
The search condition at dynamo db is:
conditions.Add(new ScanCondition("CreatedOn", ScanOperator.Between, startDate, endDate ));
If the user selects from the calendar the start date as "08-20-2018" (2018-08-20T04:00:00.000Z) and the end date is "08-21-2018"(2018-08-21T04:00:00.000Z), the code all the data created b/w these 2 dates.
Now the issue is if they select same start and end date then the code does not returns any data, I believe because the start and end date is "2018-08-21T04:00:00.000Z" and the time part of this is all 0000 etc.
My question is how can I convert the date from my calendar ie my end date to correctly reflect the the end time which they select. I havent used ISO8601 format before so not sure how can I do so.
Thanks
You don't need moment for this. You can zero out the time using a Date in the following way.
const date = new Date('2018-08-21T12:58:08.7823906Z')
date.setUTCHours(0)
date.setUTCMinutes(0)
date.setUTCSeconds(0)
date.setUTCMilliseconds(0)
Then you can simply use toISOString() to format the date.
date.toISOString()
// returns '2018-08-21T00:00:00.000Z'
If you don't want to zero out the time, and instead want to set some specific time, you can use a similar approach, just substitute the 0 with whatever time you want.
Some other things to note: DynamoDB doesn't require any specific formatting for dates. DynamoDB simply does a string or number comparison depending on what the field is defined as. You could store your dates in DynamoDB as integers or another string format if you feel that would be easier to work with.
Also, I'm not sure how your table is setup but make sure that your "CreateOn" field is the Range key and that you are using Query, not Scan. Using the Scan operation doesn't scale well.

Number of monthly occurrences of bill date between pay dates

For information; today is 24/01/2018.
I have formulas that put my previous pay date in a cell of a worksheet named in the format "YYYYMM". In this case cell 201712!B1, which is based on the month of the last pay date that has occurred.
The next pay date is in template!b1.
The date a bill comes out of my account is in [#[start date]]
The best formulas I've managed to come up with at the moment are the array formulas:
To work out how many times payments have occurred:
{=SUMPRODUCT(--(TEXT(ROW(INDIRECT(INDIRECT(TEXT(DATE(YEAR(TEMPLATE!$B$1),MONTH(TEMPLATE!$B$1)-1,DAY(TEMPLATE!$B$1)),"yyyymm")&"!$b$1")&":"&DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())))),"dd")=TEXT([#[START DATE]],"dd")))}
The above seems to be functioning okay... but I'm now questioning it, as
To work out how many times payments will still occur I have:
{=SUMPRODUCT(--(TEXT(ROW(INDIRECT(DATE(YEAR(TODAY()),MONTH(TODAY()),DAY(TODAY())+1)&":"&TEMPLATE!$B$1-1)),"dd")=TEXT([#[START DATE]],"dd")))}
My last pay date was 22/12/2017 and my next pay date is 25/01/2018.
The second formula is showing that I still have one payment left to make for a payment that occurs on the 25th of every month within this pay period of which today should be the last day.
I think I may be overcomplicating this... any help would be much appreciated.
Your second formula malfunctions because of how ROW function works, for example ROW(3:1) gives you the same as ROW(1:3) so in your formula when today+1 is after next payday-1 you still get both those dates, hence counting a payment date that's out of range
Why not just check if bill dates are after today, but before the next payday, like this:
=COUNTIFS([#[START DATE]],">"&TODAY(),[#[START DATE]],"<"&TEMPLATE!$B$1)
For bills paid between last payday and today inclusive you can do a similar thing, i.e.
=COUNTIFS([#[START DATE]],">="&INDIRECT(TEXT(EDATE(TEMPLATE!$B$1,-1),"yyyymm")&"!B1"),[#[START DATE]],"<="&TODAY())

Schedule Nintex Workflow on every 15th of the month querying SP List

I have a SP Custom List with events matrix. I have a Start Date, End Date. I would like to gather all the events from the list that has a start date between 15th of the current month to 15th of the next month and send email notification with details of all those events.
I would like to schedule this workflow to run on every 15th of the month.
Please advise.
Thank you!
For this you would need to build a site workflow because this can be scheduled.
To get the workflow completed:
Step 1. From the workflow use the calculate date action to store the date variable to check for (I.E. between 15th and 15th). Step 2. Use the query list action to find all items (events) that meet that criteria. Step 3. Send email to owners/participant or whomever on those events.

Datefield compare and validate in Angularjs

I'm looking for a way to validate two input datefields in my form.
I have a start date and end date
and conditions to check are
1.start date should not be greater than end date
2.end date should not be less than start date.
I'm trying to create a directive, if there is already a solution, can you please share.

Resources