Forum Discussion
Hi Christwr,
It worked for me. Thanks…
Can I ask something more here.
If I get the Week number as 9 then I want the Start Date as 2019-02-25 00:00:00 and End Date as 2019-03-03 23:59:59 as in Week 9 we have date as February 25, 2019 to March 3, 2019
Thanks,
Gaurav Sandil
Hi Gaurav,
Start Date:-Date.parse(_date).minusMonths(Date.parse(_date).getMonth()-1).minusDays(Date.parse(_date).getDate()-1).plusDays(Date.parse(_date).toLocaleDateString({“format”:“w”})*7-8)
End Date :- Date.now().minusMonths(Date.now().getMonth()-1).minusDays(Date.now().getDate()-1).plusDays(Date.now().toLocaleDateString({“format”:“w”})*7-8).plusDays(6)
This might help you to achieve what you are trying.
- gaurav_sandil7 years agoNew Contributor III
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)
- deepak_shaw4 years agoContributor
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.