cancel
Showing results for 
Search instead for 
Did you mean: 

Find the Current Week and Previous Week

gaurav_sandil
New Contributor III

Hi,

I am looking for a function which can give me the Current Week.
For instance the current date is 2019-03-01 , so the week would be Week 9 and the Previous week is Week 8.

Thanks,
Gaurav Sandil

6 REPLIES 6

Thanks Ajay. I tried below statement and it worked for me:

$weekstartdate =
Date.now().minusWeeks(1).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0)

$weekenddate = Date.now().minusWeeks(1).plusDays(6).withHourOfDay(23).withMinuteOfHour(59).withSecondOfMinute(59).withMillisOfSecond(0)

Hi @gaurav.sandil and @Ajay_Chawda,
I think the above expression only limits to the current month, if beginning of the week falls to last month it doesn’t calculate correctly.