Jquery datepicker weekends exclude from calcul - datepicker

How can i exclude weekends from min/max date calculation ?
Example : if the date is 15 oct , i can select only 5, 6 9, or 10 nov.
beforeShowDay: $.datepicker.noWeekends,
minDate: "+14D",
maxDate: "+19D",

Related

Run trigger at specific date and time

I want to run a trigger at specific date and time (+or - 15 min).
I have a date min string with YYYY-MM-DD HH:MM format say 2017-04-01 18:05 How will I modify the below script to run at 18 hours and 5 minutes.
var triggerDay = new Date(2017, 04, 01);
ScriptApp.newTrigger("myFunction")
.timeBased()
.at(triggerDay)
.create();
You can try this:
function createTimeDrivenTriggers() {
// Trigger on 2017-04-01 around 18:00 (±15 min).
ScriptApp.newTrigger('myFunction')
.timeBased()
.atDate(2017, 04, 01)
.atHour(18)
.create();
}
https://developers.google.com/apps-script/reference/script/clock-trigger-builder
// the full Date constructor is:
// new Date( year, month, day, hour, min, sec, ms )
var triggerDay = new Date(2017, 3, 01, 18, 5);
ScriptApp.newTrigger("myFunction")
.timeBased()
.at(triggerDay)
.create();
I'm pretty sure that the month in the constructor is zero-based (January==0), so, I changed the 04 to a 3.

Shieldui datepicker restrictions

I try to get current year in calendar.. now year is 2016 so i don't want past years and future years only want current year ... and also month is June or any other month so i don't future months only want current and past months . when year 2017 then in calendar must be year 2017 ..when month is June or any other month then not able to select future months .. we only select only current month and past months according to year
e,g, current month is June so
Jan 2016.... June 2016
this is what i try but this always show past and future months /years/days
<script type="text/javascript">
$(function() {
var currentYear = (new Date).getFullYear();
var currentMonth = (new Date).getMonth();
var currentDay = (new Date).getDate();
$('#fromdate').shieldDatePicker({
minDate: new Date((currentYear - 1), 12, 1),
//minDate: 0,
dateFormat: 'yy-mm-dd',
maxDate: new Date(currentYear, currentMonth, currentDay),
//maxDate: new Date((currentYear + 1), 12, 1),
onSelect: function(selectedDate) {
// Start Date
var startDate = $(this).shieldDatePicker('getDate');
$('#todate').shieldDatePicker('option', 'minDate', startDate);
$('#todate').shieldDatePicker('setDate', startDate);
// End Date
var enddate = $(this).shieldDatePicker('getDate');
enddate.setDate(enddate.getDate()+ 7);
$('#todate').shieldDatePicker('option', 'maxDate', enddate);
}});
$('#todate').shieldDatePicker({
minDate: new Date((currentYear - 1), 12, 1),
minDate: 0,
dateFormat: 'yy-mm-dd',
maxDate: '+7'
});
});
</script>
You can use the min and max values to set the dates.
This is demonstrated in the following snippet:
http://jsbin.com/vixiqo/3/edit?html,output
The calendar is restricted to the current year.

SharePoint custom list date and time validation

I have a custom list that I'm trying to restrict data entry for valid day of week and time.
My current column validation works for day of week being Monday, Wednesday or Friday. It looks like this:
=CHOOSE(WEEKDAY([Requested date for approval]),FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE)
I'm trying to figure out the syntax to add that it also has to be between 8 am and 12:00 pm on those days.
Any help would be greatly appreciated.
You would use an AND statement to include a second criteria
=AND(CHOOSE(WEEKDAY([Requested date for approval]),FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE),
AND(
[Requested date for approval]-INT([Requested date for approval])*24 >= 8,
[Requested date for approval]-INT([Requested date for approval])*24 <= 24
)
)
I confess, I've never heard of the CHOOSE function, but the time calculation is based on the information at Microsoft
Convert times
To convert hours from the standard time format to a decimal number, use the INT
function.
Column1 Formula Description (possible result)
10:35 AM =([Column1]-INT([Column1]))*24 Number of hours since 12:00 AM (10.583333)
12:15 PM =([Column1]-INT([Column1]))*24 Number of hours since 12:00 AM (12.25)
EDIT
To calculate the day of the week, you can use the TEXT function to return the day of the week (i.e. Monday)
=TEXT(WEEKDAY([ColumnName]), "dddd")
It won't be pretty, but you can use a series of AND logical operators
=AND(
TEXT(WEEKDAY([Requested date for approval]), "dddd") = "Monday",
AND(
TEXT(WEEKDAY([Requested date for approval]), "dddd") = "Wednesday",
AND(
TEXT(WEEKDAY([Requested date for approval]), "dddd") = "Friday",
AND(
[Requested date for approval]-INT([Requested date for approval])*24 >= 8,
[Requested date for approval]-INT([Requested date for approval])*24 <= 24
)
)
)
)
Posting Working Solution
=IF(
AND(
CHOOSE(
WEEKDAY([Requested date for approval]),FALSE,TRUE,FALSE,TRUE,FALSE,TRUE,FALSE
),
([Requested date for approval]-INT([Requested date for approval]))*24>=8,
([Requested date for approval]-INT([Requested date for approval]))*24<=12
),
TRUE
)

How to format a date in Ext JS 3?

I have a date value like this ;
Date {Fri Feb 13 2015 02:00:00 GMT+0200 (GTB Standart Saati)}
I get it from a grid column with ;
selectionModel.getSelected().data['date'];
And column model date format is 'd/m/Y'. It shows in grid well (d/m/Y).But when i get selected value it returns a date format doesn't like 'd/m/Y'. How can i format this date to set to a textfield ?
According to ExtJs Docs
var d = new Date(1993, 6, 28, 14, 39, 7);
println(d.toString()); // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
println(d.toDateString()); // prints Wed Jul 28 1993
Edit:
Please use Ext.Date.format to format the date:
Ext.Date.format(d,'d/m/Y');
According to ExtJS 3.4 Docs Date object is extended with .format() method.
So you should be able to just do
var d = new Date();
d.format("d/m/Y");

Datepicker minDate today and maxDate 31 Dec Next year

Try to limit the date selection between today and 31st Dec of next year.
$(function() {
$('.public-holiday-date-pick').datepicker({
minDate: '0',
yearRange: '-0:+1',
maxDate: ???
hideIfNoPrevNext: true
});
});
How should I define maxDate ? tried few things like '31 12 +1', or just 'last day of next year', did not work.
1) First get today's using
var today = new Date();
2) Similarly set the lastDate as below
var lastDate = new Date(today.getFullYear() +1, 11, 31);
The value in lastDate will be like
lastDate = 31 December, today's year +1
Finally set the lastDate as maxDate
var today = new Date(); //Get today's date
var lastDate = new Date(today.getFullYear() +1, 11, 31); //To get the 31st Dec of next year
$(function() {
$('.public-holiday-date-pick').datepicker({
minDate: '0',
yearRange: '-0:+1',
maxDate: lastDate, //set the lastDate as maxDate
hideIfNoPrevNext: true
});
});
JSFiddle