function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Yoshinori MoriYoshinori Mori 

Select Ysar, Month, Day by using combobox

I'd like to obtain sample codes for Salesforce to select Year,Month,Day all by using combobox.

I'd like to select Year,Month then Day.

When selecting after Month, The number of Day needs be retrieved according to the number of actual days for the month. For example, Jan should have 31 days, on the other hand, Feb should have 28 days.

I appreciate if any member of the discussion boards provide me with the sample codes and also give me an idea of how the YMD object also needs to be prepared and configured.

 

Thanks

 

Mori

Best Answer chosen by Admin (Salesforce Developers) 
super developersuper developer

For this you need just  logic that's it.

 

Take 3 picklist .

one for year,month,day.

 

i think you know how to add dynamically selectoptions. to combo box.

first picklist for year you can add dynamically.

 

second one for month

 

3 one for day for this need to maintain a map for map<string,integer>  month= new map<string,integer>{january=>31,march=>31} like this except feb

 

for feb take another map<string,integer> feb1= new map<string,integer>{febrauary=>28} similarly  

map<string,integer> feb2= new map<string,integer>{febrauary=>29}

if(year/4==0) call feb2 other wise call feb1;

 

it's need logic it's not complex code but some what lenghy to write.

 

why you need this for date you can use direct date field of object like<apex:inputfield value="{!object.datefield__c}"/>

 

 

All Answers

super developersuper developer

Hi Mori,

 

We can do this in Vf pages with apex class.

Yoshinori MoriYoshinori Mori

Could it be possible to provide sample code for this?

I appreciate if it is just a part of it.

 

Thanks

Mori

super developersuper developer

For this you need just  logic that's it.

 

Take 3 picklist .

one for year,month,day.

 

i think you know how to add dynamically selectoptions. to combo box.

first picklist for year you can add dynamically.

 

second one for month

 

3 one for day for this need to maintain a map for map<string,integer>  month= new map<string,integer>{january=>31,march=>31} like this except feb

 

for feb take another map<string,integer> feb1= new map<string,integer>{febrauary=>28} similarly  

map<string,integer> feb2= new map<string,integer>{febrauary=>29}

if(year/4==0) call feb2 other wise call feb1;

 

it's need logic it's not complex code but some what lenghy to write.

 

why you need this for date you can use direct date field of object like<apex:inputfield value="{!object.datefield__c}"/>

 

 

This was selected as the best answer
Yoshinori MoriYoshinori Mori

Thank you your help

Recently, I just began programming work.

 

Mori

sarvesh001sarvesh001
Hi Mori
can you shre the code for display no of days of selected month of selected year