You need to sign in to do that
Don't have an account?

Date picker functionality
Hi,
I'm having a VF page with two fields Start Date & End Date.
Using date picker I'm getting the calendar, But the problem is when I open that page automatically Start date , End date values must be populated based on the current month.
For example: If I go to that VF page, as this month is september , start date must be 9/1/2016, End date must be 30/1/2016.
First date and Last date of the current month must be populated.
Please help me
I'm having a VF page with two fields Start Date & End Date.
Using date picker I'm getting the calendar, But the problem is when I open that page automatically Start date , End date values must be populated based on the current month.
For example: If I go to that VF page, as this month is september , start date must be 9/1/2016, End date must be 30/1/2016.
First date and Last date of the current month must be populated.
Please help me
Try the below code in your apex class.
public date startdate{get;set;}
public date enddate{get;set;}
date highclose = Date.today();
Integer numberDays = date.daysInMonth(highClose.year(), highClose.month());
startdate = Date.newInstance(highClose.year(), highClose.month(), 1);
Enddate = Date.newInstance(highClose.year(), highClose.month(),numberDays);
Hope this helps.
Thanks
All Answers
Try the below code in your apex class.
public date startdate{get;set;}
public date enddate{get;set;}
date highclose = Date.today();
Integer numberDays = date.daysInMonth(highClose.year(), highClose.month());
startdate = Date.newInstance(highClose.year(), highClose.month(), 1);
Enddate = Date.newInstance(highClose.year(), highClose.month(),numberDays);
Hope this helps.
Thanks
If my answer fixed the issue, please mark as resolved so that the answers may help others.
Thanks