S
S
Sergey Kiselyov2021-09-29 00:17:14
JavaScript
Sergey Kiselyov, 2021-09-29 00:17:14

How to calculate current week number?

I ask for help,
how can I calculate the week number for a specified date, there is numweek, but I wanted to know what other options are there)))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2021-09-29
@sTantal

mathematically (without taking into account the days of the week), the seven-day number = int((N+6)/7),
where N is the ordinal number of the day in the year,
int() is the discarding of the fractional part of the number.
But we need to agree on where to start counting the first week.
For example, January 1, Saturday. There are options (in Britain, the week starts on Sunday):
1 - 1st week, 2-8 - 2nd week, ..
1 - 0th week (because it is incomplete), 2-8 - 1st week, ..
1.2 - 1st week, 3-9 - 2nd week,..
1.2 - 0th week (because incomplete), 3-9 - 1st week,..

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question