How to show reminder by month?
I have created this partial code and I am stucked how to manipulate to check and get reminder by month.
reminders = ScheduledActionService.GetActions<Reminder>();
if (reminders.Count<Reminder>() > 0)
{
}
else
{
}
If there is reminder I want to check the month and get the month i want.
try this one:
var month = 5; // your month
var remindersOfMonth = ScheduledActionService.GetActions<ScheduledAction>()
.Where(a=> a.BeginTime.Month == month);
According to this when you use GetActions() it will return you a list of
ScheduledAction. Now according to this ScheduledAction has a property called BeginTime which is of type DateTime so it has Month property which is your interest.
variable "a" in the statement is in fact each of ScheduledAction in the collection which are begin evaluated again the month.
Related
I am working on dates in Laravel. I have to set dates for patient future injections.
To keep it simple, let's suppose today is 13-03-2019 (Wednesday).
I created first date as:
$firstDate = Carbon::create(2019,03 ,18, 12); // The day is Monday
// set date
Carbon::setTestNow($firstDate);
Now I want the next two appointments should be on Wednesday and Friday. So I again set the dates as follow:
// set second date
$secondDate = new Carbon('Wednesday');
Carbon::setTestNow($secondDate);
// set thirdDate
$thirdDate = new Carbon('Friday');
Carbon::setTestNow($thirdDate);
According to above example the output should be:
2019-03-18
2019-03-20
2019-03-22
But the problem is that it outputs the first set date correct but print the 2nd and 3rd date wrong as it considers 'Wednesday' of next week as today's date.
So the Output print as:
2019-03-18
2019-03-13
2019-03-14
I have spent a lot of time on it, I would appreciate if anyone of you people could help me in this.
I would appreciate if anyone guides me where I am going wrong.
Thanks.
As the setTestNow() function was not working for 2nd and third date/days, so I first get all three required days then convert them to 'dayOfWeek' which returns day number (Sunday 0, Monday 1 and so on...). I subtracted the first day from second and third day and then finally add these days to the date that i get from the datepicker.
// set the start date
if( $visitstart_date != null && $visitstart_date != '') {
Carbon::setTestNow($visitstart_date);
} else {
Carbon::setTestNow();
}
if($perweek_visit1_day != '')
{
//Get first selected day number
$firstDay = Carbon::parse($perweek_visit1_day)->dayOfWeek;
$perweek_visit1_dayDate = Carbon::now();
}
if($perweek_visit2_day != '')
{
//Get second day numer
$secondDay = Carbon::parse($perweek_visit2_day)->dayOfWeek - $firstDay;
$perweek_visit2_dayDate = Carbon::now()->addDays($secondDay);
}
if($perweek_visit3_day != '')
{
//Get third day number
$thirdDay = Carbon::parse($perweek_visit3_day)->dayOfWeek - $firstDay;
$perweek_visit3_dayDate = Carbon::now()->addDays($thirdDay);
}
I have events (from an Event model) that have a starts_at: value in the form of a datetime. e.g.:
2016-02-18 11:00:00:00000
What I want to be able to do is check whether an event is starting this week.
I want to be able to make a list of events that are occuring this week (starting from the latest Monday).
#events = #calendar.events.where( ... )
I thought something along the lines of this:
start_week = Date.today.beginning_of_week(:monday).day()
end_week = Date.today.beginning_of_week(:monday).day()+6
range = start_week..end_week
#events = #calendar.events.where(starts_at: in range)
But it doesn't take into account the month or year. Also I'm not sure how to write the 'where' clause. How should I go about doing this? Thanks
Try this:
start_week = Date.today.beginning_of_week(:monday)
end_week = Date.today.beginning_of_week(:monday)+6
range = start_week..end_week
#events = #calendar.events.where(starts_at: range)
Assuming you want all the events from the current week, something like this should work:
#events = #calendar.events.where(starts_at: Time.zone.today.all_week)
all_week returns a Date range covering the current week.
I want to validate Start date and End date how should I write in web resource?
I have tried some code but it doesn't work. The function is continuously repeating after some time. But it should be stop once executed.
Please help me on this.
function ValidateEndDate(econtext)
{
var sdate = Xrm.Page.getAttribute("new_startdate");
var edate = Xrm.Page.getAttribute("new_enddate");
var eventArgs = econtext.getEventArgs();
if (sdate.getValue() > edate.getValue())
{
alert("End date should be greater than");
sdate.setValue(null);
eventArgs.preventDefault();
}
}
I am using KendoUI scheduler in my application. is there any way to get the start of week when the selected view is week.
Yes. Use the navigate event to catch current date and get the start of week by manipulating the retrieved date. i.e.
navigate: function (e) {
if (e.view.toLowerCase() === "week") {
GetStartDateOfWeek(e.date);
}
}
function GetStartDateOfWeek(d) {
d = new Date(d);
var day = d.getDay(),
diff = d.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday
var startOfWeek = new Date(d.setDate(diff));
}
Hope it helps!
Reference: JavaScript - get the first day of the week from current date
I an using kendodate picker in my solution.I want to retrieve the dates for full week whenever user selects some date from the kendodatepicker.e.g.lets say today is Feb 21,2014(Friday) whenever user selects some day say Feb 24,2014(Monday) then i need to retrieve its week's dates(starting and ending date).the answer should be(Feb 22,2014-Feb 28,2014)considering the fact that my week starts from Saturday(Feb 22)and ends on Friday(Feb 28).Kindly guide.i am new very much new to kendoUI.thanks
Define the change event handler as:
change : function (e) {
// Get a reference to the row (week) containing the selected date
var tr = $(".k-state-selected", cal._table).closest("tr");
// Get the first day
var first = $("td:first", tr).text();
// Get the last day
var last = $("td:last", tr).text());
}
Example here : http://jsfiddle.net/OnaBai/W9VFB/9/
If you want to have the first and last date as text, then you might use:
var first = $("td:first", tr).find("a").attr("title");
var last = $("td:last", tr).find("a").attr("title");
Example here : http://jsfiddle.net/OnaBai/W9VFB/12/