0
Date currentDate = System.today();
System.debug('Start of week = '+currentDate.toStartOfWeek()); 

For English (United States) locale System.debug will display Sunday date as Start of week. And for English (United Kingdom) locale System.debug will display Monday date as start of week.

Irrespective of user's locale, Always I need to get Sunday date as week start date. Is it possible?

  • You can subtract one day from current date, If you get Monday as the startOfWeek. Date currentDate = System.today().toStartOfWeek().addDays(-1); somthing like this. – Rahul May 13 at 11:05
0

One way of doing it is below:

Documentation of date time class

Datetime currentDatetime = System.now();
date gmtdate = currentDatetime.dateGMT();
System.debug('gmtStart of week = '+gmtdate.toStartOfWeek()); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.