Date picker not showing december month - datepicker

I am using below jquery to show date picker I have multiple date select box. It is working properly .However it is not showing december month. Please help me here is my code
$('.datepicker').live('focus',function(){
$(this).datepicker({
dateFormat: 'dd-mm-yy',
changeMonth: true,
changeYear: true,
yearRange: '1900:' + new Date().getFullYear(),
maxDate: 0
})
});

having maxDate = 0 is the reason you don't see Dec in the month drop down since this question was posted in Nov. If you pick a different year, you will be able to see Dec in the month drop down.

I found the issue it was due to maxDate: 0.
I have changed maxDate: -1 to solve the issue.
Thanks #kimdung and #Anthony C you you kind help

The only thing you have to do is add +2 to the maximum date, so I will let you see the month of December, if you put -1 it will take away a month, it may be the current month, I had the same problem and so it was corrected. maxDate: "+ 2M".

Related

how to add weeks,month, year to a date in flutter

I have a date string in flutter which i am trying to add week, month and year but not sure how to do it.
in android java, we can add weeks, month, year in the following way
Calendar cal = Calendar.getInstance();
cal.setTime('2019-09-04');
cal.add(Calendar.WEEK_OF_MONTH,1); // add one week
cal.add(Calendar.WEEK_OF_MONTH, 2 ); // add two weeks
cal.add(Calendar.MONTH, 1); // add # of month
cal.add(Calendar.MONTH, 3); // add 3 months
cal.add(Calendar.YEAR, 1); // add 1 year
however, i dont know how to add this in flutter. i know i can use duration but it only accept number of days cal.add(new Duration(days: 30));
if i use duration, then i need to figure out how many number of days in a month, week, or year and it is more math. with the above code in android java, adding weeks , months or year will be taken by android. is there a way for flutter to add weeks, months or year to a date?
for example: if i have 01/31/2019 and i want to add a month then new date should be 02/28/2019. if i want add a month to 02/28/2019 then output should be 03/31/2019
same goes for weeks and years. flutter should add a week to a date if specify or a year and so on. thanks in advance
You can find everything you need on this medium article:
Top 7 Date methods
Let's suppose you have '2019-09-04', in Dart you have:
var myDate = DateTime.parse("2019-09-04 20:18:04Z");
myDate.add(Duration(days: 10, hours: 5)));
then print it out:
print(myDate.toLocal());
EDIT:
because of your comment below, to add years or month do as follow:
var date = new DateTime(2019, 9, 4);
var newDate = new DateTime(date.year + 1, date.month + 2, date.day);
You can find similar answer here: Add/Substract months/years to date in dart?

My selected date is showing one day before in Ionic 4

I am working in my Ionic 4 app and I have used a native datepicker for that and I am converting the date to toISOString() but the problem is that it is showing one day before.
This is my ts:
this.datePicker.show({
date: new Date(),
mode: 'date',
androidTheme: this.datePicker.ANDROID_THEMES.THEME_HOLO_DARK,
}).then(
date => {
me.acceptchallengeform.setValue({
startchallenge: new Date(date).toISOString().split('T')[0],
});
console.log('Got date: ', date)},
err => {
console.log('Error occurred while getting date: ', err)}
);
var DatePickerDate ='Thu Aug 09 2018 00:00:00 GMT+0100 (British Summer Time)';
var myDate = new Date(DatePickerDate).toISOString().split('T')[0];
so myDate is now 2018-08-08
The problem is that it is showing the date one day before.
But I want to show the exact selected date.
Any help is much appreciated.
new Date() return the date using your system timezone.
toISOString() return the date in UTC and the time part of your date is midnight, so it returns Thu Aug 08 2018 23:00:00 (BST - 1h), that's why you're getting one day before.
What are your trying to do exactly?
Editing my answer following comment
in your case I would choose the easy way as you apparently don't need any timezone information:
startchallenge: date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate();
or you can use moment.js (http://momentjs.com/docs/#/displaying/format/)
Try This:
date = new Date(date.setDate(date.getDate() + 1));
me.acceptchallengeform.setValue({
startchallenge: new Date(date).toISOString().split('T')[0],
});
This will solve your problem.

How do I Determine The Number Of Days In A Month from a particular date in angularjs 2?

I am using angularjs 2 and type script.
I want the number of days in a month from a particular date given by user.
How do I Determine that?
Please help. Thanks in Advance.
As pointed out by Evgeny Shmanev, this answer is incorrect. Please see the correct answer by Zvi Tarem
You don't need angular, you can call this function:
function daysRemainingInMonth(date) {
var year = date.getYear();
var month = date.getMonth();
return new Date(year, month, 0).getDate()
}
Edit: Updated now that I know you have the date
It may be a bit late, but the right answer is a follows:
In order to find the number of days in a month, you need to get the 'date' of the 0th day of the next month:
let daysInMonth = new Date(year, month + 1, 0).getDate();

Crystal Date Parameter for last year

I have tried using this formula with a date parameter. It works for the other 11 months but not the 12th month. Could some one please let me know what additional code I need to add to the formula.
If {?End Date} = 12/14/13
I want the formula to = 12/31/12
This is what I have been using to make it work for the other 11 months.
Date(year({?End Date})-1, month({?End Date})+1,1) - 1
I receive an error that the month needs to be 1 - 12.
Any suggestions will be greatly appreciated.
Thanks
This will give you the last day of the month of the previous year:
DateAdd("m", 1, DateTime( Year({immaster.timestmp})-1, Month({immaster.timestmp}), 1, 0,0,0 )) - 1
Try this.
CDate(Year(DateAdd ('yyyy',-1,CurrentDate)),Month(DateAdd ('M',0,CurrentDate)),31)

Previous month in parameter

I need to set a Hidden Default Parameter in SSRS.
In my query I need to not show last months total but the month before that, ie in Feb I need to show Dec totals.
I usually use this for last month but cannot tweak it for the month prior.
Set first date of last month:
=DateAdd("m", -1, DateSerial(Year(Now()), Month(Now()), 1))
Set last date of last month:
=DateAdd("d", -1, DateSerial(Year(Now()), Month(Now()), 1))
If i understand you right you want to:
Get the first day of two months from now
=DateAdd("m", -2, DateSerial(Year(Now()), Month(Now()), 1))
And you want to get the last day on month two months from now
=DateAdd("d" , -1 , DateAdd("m", -1, DateSerial(Year(Now()), Month(Now()), 1)))
Depending on exactly what you need, use something like:
DateAdd
(
DateInterval.Month
, -1
, DateAdd(DateInterval.Day, -1, DateSerial(Year(Parameters!Date.Value), Month(Parameters!Date.Value), 1))
)
Used in a report: