Kendo UI Scheduler - Check is date in recurrence rule - date

I have recurrence rule(for example like "FREQ=WEEKLY;BYDAY=WE"), start date and end date.
Where can I find method or function to check is current date enters in my rule or not?
For example if I have:
Start date: 01.02.2017
End date: 03.02.2017
Recurrence rule: "FREQ=DAILY;NTERVAL=5"
So, in this case date 4.02.2017 not enters in this rule, but date 5.02.2017 enters in this rule.

You can use the scheduler's occurrencesInRange method like this:
var scheduler = $("#scheduler").data("kendoScheduler");
var events = scheduler.occurrencesInRange(
new Date("2017-02-05"), // The date you want to check at 0:00 am
new Date("2017-02-06") // The same date + 24 hours
);
You'll get a list of recurring dates in that date. If the array isn't empty then the start date you supplied the above method has an occurance in it.

Related

Create agent and give its population different id/names and stop each id delay on different time

I have an agent and set its parameter Name and give 3 different names
What I want to do is stop the delay of each name on a different calendar date. How I can achieve that?
You can get the current year, month and day with the following functions:
int getYear(Date date) — returns the year of the current date.
int getMonth(Date date) — returns the month of the current date: one of the constants JANUARY, FEBRUARY, etc.
int getDayOfMonth(Date date)— returns the day of the month of the current date: 1, 2, …
Based on these, you can get the first agent in the delay block with delay.get(0) and use if function.
Pseudo-code like this;
if (date==x){
if (delay.get(0)==myAgents.get(0)){
stopDelay(delay.get(0));
}
}
or
if (date==x){
if (delay.get(0).Name=="yyy"){
stopDelay(delay.get(0));
}
}

Calculate a Reference Date in DAX

Trying to nail down the syntax for a pretty straightforward problem.
I have a table called Events and a full-feature DATES table with a relationship between the Dates[Date] field.
Using the event name as a slicer, I trying to create a [First Monday] measure that will return the date of the first Monday of the month.
So for example, if my event date was 2/14/19, [First Monday] would return 2/4/19.
Your Date table needs to contain 2 columns:
Year-Month: for example, "2018-01"
Weekday Number: for example, 1 (for Monday); or Weekday Name (i.e, "Monday")
Then:
First Monday =
CALCULATE( MIN('Date'[Date]),
ALL('Date'),
VALUES('Date'[Year-Month]),
'Date'[Weekday Name] = "Monday")
How it works:
First, we need to access all dates in the Date table, so we use ALL()
Second, we need to see only dates for the current context year and month, for which we can use VALUES()
Third, for each month we only want Mondays, hence Date[Weekday] = "Monday"
All this unfiltering/filtering generates a set of Mondays for the Year-Month visible in the current filter context. All we need to do now is to find the earliest of the Mondays using Min(Date).

How to create a specific date in Google Script

I have a spreadsheet that asks people to enter in a day of the month when we need to send out a bill. What I want to do is create a calendar event based on that. So, essentially what I need is an event that starts at the current month, day from the spreadsheet, and continues to a specified point in time.
var monthlyDate = row[6]; // Seventh column, monthly date of payment
var curDate = new Date();
var curMonth = curDate.getMonth();
var curYear = curDate.getYear();
curDate.setDate(curMonth, monthlyDate, curYear);
Logger.log("Day of month: %s", monthlyDate);
Logger.log("Current Date: %s", curDate);
Logger.log("Current Date: %s", Date());
What I'm seeing is that the monthly date is coming in as a float "6.0" for example, and no matter what I enter in for monthlyDate in the setDate line, it keeps setting the date to 10/9/15 (Today is 10/15/15). I've hard-coded that value to many different numbers, but for some reason it's just not working.
How can I create a date (in any format) that follows the scheme "Current Month / Day from Speadsheet / Current Year" ?
The getMonth() method returns a "zero-indexed" number. So, it returns the number 9 for the 10th month. setDate() doesn't set the date, it sets the "Day of the Month". The name of that method is misleading.
Documentation - setDate()
So, the last two parameters that you are using in setDate() are doing nothing. You are setting the day of the month to 9.
If you want to set multiple date parameters at the same time, you need to use the new Date() method:
var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);
The month parameter accept values from 0 to 11, 0 is Jan and 11 is Dec
Date Reference

MS Access 2010 (Design View): return Monday of the current week with Monday as 1st day of the week

I need to make my Access query always return the Monday of the current week. I have seen a few solutions on Google/StackOverflow but they are written in SQL and I am a beginner in creating Access queries (I am using the Design view to make them).
Goal: The week should be considered as M T W T F S S. Then, the query should always return the Monday of the current week. Therefore, if it is Sunday, it should still return the Monday before, NOT the next week's Monday. Can anyone explain how to do this using the Design View in Access 2010?
Keep in mind that in this context we are working with dates, so if we do Date() - 1, we will get 1 day prior to today.
Date() ~ Today's date
DatePart(
"w" - Weekday
Date() - Today's date
2 - vBMonday (Access assumes Sunday is the first day of the week, which is why this is necessary.)
1 - vbFirstJan1 - This gets into using the first week of the year. We could have omitted this, as 1 is the default.
)
-1 - Subtract 1 from the DatePart value.
Values
Date() = 4/27/2015 (at time of this writing)
DatePart("w",Date(),2,1) = 1
DatePart("w",Date(),2,1)-1 = 0
So we have Date()-0... Okay, what's so great about that? Well, let's look at a more useful scenario where today's date is a day other than Monday.
Let's act like today is 4/28/2015 (Tuesday)
Date() = 4/28/2015
DatePart("w",Date(),2,1) = 2
DatePart("w",Date(),2,1)-1 = 1
So, from the outside, in; give me the current weekday value. (1 = Monday, 2 = Tuesday, etc.), and subtract 1 from that -> that's how many days we need to subtract from the current date to get back to the weekday value of 1 (Monday).
Here's a function that will do this:
Public Function DatePrevWeekday( _
ByVal datDate As Date, _
Optional ByVal bytWeekday As VbDayOfWeek = vbMonday) _
As Date
' Returns the date of the previous weekday, as spelled in vbXxxxday, prior to datDate.
' 2000-09-06. Cactus Data ApS.
' No special error handling.
On Error Resume Next
DatePrevWeekday = DateAdd("d", 1 - Weekday(datDate, bytWeekday), datDate)
End Function
As vbMonday is 2 and your date is today, you can use the core expression in a query:
PreviousMonday: DateAdd("d",1-Weekday(Date(),2),Date())

Dynamics crm onchange event Validating if a specified date falls within a date range

I am trying to set up an onchange event within MS Dynamics CRM that brings up an alert if a date entered in a field falls outside of a specified range.
{
if (crmForm.all.fielddate.DataValue < 01/01/2010 || crmForm.all.fielddate.DataValue >= 01/01/2011)
{
alert("Specified date falls outside of the date range") ;
}
}
This doesnt seem to work, am I using the correct date format? or am I missing something out?
Thanks in advance for your help
Brett
You'll need to parse each value as a date before comparing:
if (Date.parse(fromDate) > Date.parse(toDate)) {
alert("Specified date falls outside of the date range");
}