Page 1 of 1
Week number in a Year
Posted: Sat Jul 06, 2024 7:35 pm
by miskox
Date library has this (from the online help):
Code: Select all
AddDate
ConvertDate
Date
DateUTC
Day
DayOfWeek
DayOfYear
FormatDate
Hour
Minute
Month
ParseDate
Second
Year
Maybe it would be nice to add a function to return week number in a year.
To also have a function to return working day number in a month/year (only taking into the account working days mon-fri). Holidays are special cases (maybe could be added if holidays information is stored somewhere (array?)).
Thanks.
Saso
Re: Week number in a Year
Posted: Sat Jul 06, 2024 8:11 pm
by AZJIO
https://learn.microsoft.com/en-us/windo ... ateformata
https://learn.microsoft.com/en-us/windo ... t-pictures
Code: Select all
time.systemtime
GetDateFormat_(#LOCALE_SYSTEM_DEFAULT, 0, @time, "MMMMM", @result, 16)
GetDateFormat_(#LOCALE_SYSTEM_DEFAULT, 0, @time, "ddd", @result, 16)
Re: Week number in a Year
Posted: Sat Jul 06, 2024 8:38 pm
by jacdelad
...if you are on Windows.
Otherwise, or if you don't want to use API calls, take a look into the Tipps&Tricks section. It contains at least two Date modules. Maybe they already have this built-in; if not, I'm sure the author will add it quickly.
Re: Week number in a Year
Posted: Sat Jul 06, 2024 10:46 pm
by TassyJim
Depending on what country you are in, week number is easy with what we have.
Code: Select all
weeknumber.l = (DayOfYear(Date(2024,7,7,0,0,0))+6)/7
Debug weeknumber
This will cause much eye rolling and complaints from some countries who want every week to start on Sunday (or Monday) including for week number of the year.
Working days is trickier due to it being even more political, not logical.
Assuming 5 days a week as the official working week is the most common but not everywhere and it is a moving target.
You have the number of working days in the previous weeks ( = weeks * 5 ) and then work out the number of working days so far in the current week.
Public holidays are even more localised and would be close to impossible to keep track of.
Fortunately, I am retired so every day is a holiday...