ShowAll Questionssorted byDate Posted
SARI4

# How to calculate next meeting date based on given frequency,week and day.

Hi,

I have to write a trigger to calculate next meeting date from today. I have an object which stores input of Frequency(monthly, two month, quaterly), Day(Mon-Fri),Week (Week1 -Week 5). Based on these input how should I calculate the next meeting date from today.

example: If Frequency is "Monthly", Day is "Wednesday" and Week is "Week 3".
then I have to calculate date of next meeting which should be Wednesday of 3rd week of next month.

Thanks!

Saravana Bharathi 1
Hi,

For Reference
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm

Date nextMeetingDate;
if(Frequency == 'Monthly')
{
}
if(Week !=NULL)
{
Date nextMeetingDateStartMonth = nextMeetingDate.toStartOfMonth();
if(Week == 'Week 1')
{
}
if(Week == 'Week')
{
}
if(Week == 'Week 3')
{
}
if(Week == 'Week 4')
{
}
}
if(Day !=NULL)
{
Date nextMeetingDateStartWeek = nextMeetingDate.toStartOfWeek();
if(UserInfo.getLocale()=='en_US')
{
if(Day == 'Monday')
if(Day == 'Tuesday')
if(Day == 'Wednesday')
if(Day == 'Thursday')
if(Day == 'Friday')
if(Day == 'Saturday')
if(Day == 'Sunday')
}
else
{
if(Day == 'Monday')
if(Day == 'Tuesday')
if(Day == 'Wednesday')
if(Day == 'Thursday')
if(Day == 'Friday')
if(Day == 'Saturday')
if(Day == 'Sunday')
}
}

Thanks

Saravana Bharathi 1
Hi,

For Reference
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm

Date nextMeetingDate;
if(Frequency == 'Monthly')
{
}
if(Week !=NULL)
{
Date nextMeetingDateStartMonth = nextMeetingDate.toStartOfMonth();
if(Week == 'Week 1')
{
}
if(Week == 'Week')
{
}
if(Week == 'Week 3')
{
}
if(Week == 'Week 4')
{
}
}
if(Day !=NULL)
{
Date nextMeetingDateStartWeek = nextMeetingDate.toStartOfWeek();
if(UserInfo.getLocale()=='en_US')
{
if(Day == 'Monday')
if(Day == 'Tuesday')
if(Day == 'Wednesday')
if(Day == 'Thursday')
if(Day == 'Friday')
if(Day == 'Saturday')
if(Day == 'Sunday')
}
else
{
if(Day == 'Monday')
if(Day == 'Tuesday')
if(Day == 'Wednesday')
if(Day == 'Thursday')
if(Day == 'Friday')