02-28-2019 09:06 PM
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
03-01-2019 11:24 AM
$CurrentWeekOfYear = Date.now().toLocaleDateString({“format”:“w”})
$PreviousWeekOfYear = Date.now().minusWeeks(1).toLocaleDateString({“format”:“w”})
Can also wrap a parseInt() around it if want in number data type.
03-04-2019 01:56 AM
Thanks a lot christwr. I will definitely give it a try.
03-04-2019 02:54 AM
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
03-04-2019 09:12 AM
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.