cancel
Showing results for
Did you mean:
Post Patron

## GET WEEK NUMBER FROM CURRENT DATE

Hello All,

I would want some help to get the week number of current date. I have added the below function to get the current date. If some one could help me to get the week number it would be of great help.

convertFromUtc(utcNow(),'India Standard Time','dd/MM/yyyy')
26 REPLIES 26
Post Prodigy

So, when I use the

``add(div(dayOfYear(utcNow()),7),1)``

For Friday 29th of July 2022, I am getting week 31. It's week 30. Ideas?

Most Valuable Professional

I would need to check the exact math, but could it be doing an automatic RoundUp for a fractional week?

-------------------------------------------------------------------------
If you like my response, please give it a Thumbs Up.
Post Prodigy

@Pstork1 I went through the math. 29th of July 2022 is 210 day of the year. Divided by 7 is 30, plus 1 is 31. It doesn't seem to be a decimal issue there. I looked around and week 30 starts with 25th of July for ISO and 24th for Sunday as first day of the week.

I found another solution though, but it's strange that it's not working.

Frequent Visitor

Mathematically it is true for each year. But in real life people seem not to consider a week with less than 4 days of a new year (not entirely sure if it is always less than 4) the 1st calendar week of the year. So for some years the correct formula would be

``div(dayOfYear(convertFromUtc(utcNow(),'India Standard Time','U')),7)``

since the first 1/2/3 days of these years did not belong to the CW 1.

Kudo Kingpin

I use this Expression:

Regular Visitor

Thank you! How to get the answer to 2 digits?

Most Valuable Professional

Please post this as a new question.  You'll get more responses and others will be able to find the answer more easily later.

-------------------------------------------------------------------------
If you like my response, please give it a Thumbs Up.

Announcements