You need to sign in to do that
Don't have an account?
Cody Drennon
Is there a way to validate date based on month and year picklists
Hello,
So i have a user interface that has a month picklist and a year picklist. Each one is hardcoded with months and years and each one has an Id. There are only 4 years in the years picklist and all 12 months in the month picklist. My questions is, can these be validated for example, make sure that the end date and no greater than one year after the start date. I have been trying to figure out a way to do this for over a day now and just cant seem to figure out any logic for this. If anyone could please let me know if this is even possible i would greatly appreciate it. Thank you. This is using a custom apex page, and angular2 font end.
So i have a user interface that has a month picklist and a year picklist. Each one is hardcoded with months and years and each one has an Id. There are only 4 years in the years picklist and all 12 months in the month picklist. My questions is, can these be validated for example, make sure that the end date and no greater than one year after the start date. I have been trying to figure out a way to do this for over a day now and just cant seem to figure out any logic for this. If anyone could please let me know if this is even possible i would greatly appreciate it. Thank you. This is using a custom apex page, and angular2 font end.
The formula field should be like this:
DATE( value(TEXT(Year__c )) ,IF( ISPICKVAL(Month__c , "Jan"), 01, IF( ISPICKVAL(Month__c , "Feb"), 02, IF( ISPICKVAL(Month__c , "Mar"), 03, IF( ISPICKVAL(Month__c , "Apr"), 04, IF( ISPICKVAL(Month__c , "May"), 05, IF( ISPICKVAL(Month__c , "Jun"), 06, IF( ISPICKVAL(Month__c , "Jul"), 07, IF( ISPICKVAL(Month__c , "Aug"), 08, IF( ISPICKVAL(Month__c , "Sep"), 09, IF( ISPICKVAL(Month__c , "Oct"), 10, IF( ISPICKVAL(Month__c , "Nov"), 11, 12 ) ) ) ) ) ) ) ) ) ) ),01)
Then create a validation to compare the start and end date and throw appropriate error message.
If this works please mark this as best answers..
All Answers
The formula field should be like this:
DATE( value(TEXT(Year__c )) ,IF( ISPICKVAL(Month__c , "Jan"), 01, IF( ISPICKVAL(Month__c , "Feb"), 02, IF( ISPICKVAL(Month__c , "Mar"), 03, IF( ISPICKVAL(Month__c , "Apr"), 04, IF( ISPICKVAL(Month__c , "May"), 05, IF( ISPICKVAL(Month__c , "Jun"), 06, IF( ISPICKVAL(Month__c , "Jul"), 07, IF( ISPICKVAL(Month__c , "Aug"), 08, IF( ISPICKVAL(Month__c , "Sep"), 09, IF( ISPICKVAL(Month__c , "Oct"), 10, IF( ISPICKVAL(Month__c , "Nov"), 11, 12 ) ) ) ) ) ) ) ) ) ) ),01)
Then create a validation to compare the start and end date and throw appropriate error message.
If this works please mark this as best answers..