+ Start a Discussion
Anilkumar KotaAnilkumar Kota 

Date value in two fields

Hi ,

I have two date fields in the first field i have to show the date of first monday in a month and in the second date field monday date for current week.
Eg: In first field 1 May 2017(First Monday date in May )
      Second field 8 May 2017(Monday date for current week )

Thanks in Advance.

GauravGargGauravGarg
Hi Anil,

You can check below link, which provide an efficient way to calculate weekday and weekends of a particular day. 

https://help.salesforce.com/articleView?id=000004526&type=1

Hope this helps!!!

Thanks,
Gaurav
Skype: gaurav62990
 
Rajeshwari ShettyRajeshwari Shetty
Hi Anil,

You can use the date function "toStartOfWeek()" for the first date field.
This Returns the start of the week for the Date that called the method, depending on the context user's locale.
For example, the start of a week is Sunday in the United States locale, and Monday in European locales.
Date myDate = Date.today();
Date weekStart = myDate.toStartofWeek();
Reference:https://developer.salesforce.com/docs/atlas.enus.apexcode.meta/apexcode/apex_methods_system_date.htm#apex_System_Date_methods (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_date.htm#apex_System_Date_methods)
For the second date field i think you can add 8 das to today's date.
Date todayDate = System.today();
Date nextWeekDate = todayDate+8;

Hope this will be helpfull.

Thanks,
Rajeshwari Shetty