mgdPaul
asked on
Retrieving current week number
Hi,
I want to be able to retrieve the week number of the current date. I looked all over the MSDN help, MSDN online, and even Borland's help, but no luck. Somehow the developers of Win32 and those of VCL didn't think anyone would ever need a week number or something, cause there seem to be no functions for it. All that the date/time functions will give me is day/month/year/minutes/hou rs/seconds etc, not weeks. I was wondering if there was a function for it or something, either in Win32 or VCL (not in MFC, I'm not allowed to use MFC here).
Thanks in advance,
Paul
I want to be able to retrieve the week number of the current date. I looked all over the MSDN help, MSDN online, and even Borland's help, but no luck. Somehow the developers of Win32 and those of VCL didn't think anyone would ever need a week number or something, cause there seem to be no functions for it. All that the date/time functions will give me is day/month/year/minutes/hou
Thanks in advance,
Paul
The easiest way is to use tm_yday member of tm structure.
tm_yday/7 shall give you week number (could be that you need to add 1).
tm_yday/7 shall give you week number (could be that you need to add 1).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
I take it that there aren't any 'standard' functions or anything for this? I find working with dates and times a true hell in C/C++ .... there are dozens of functions and structures to choose from, and the help leaves it up to you to figure out why you should choose one above the other.
I take it that there aren't any 'standard' functions or anything for this? I find working with dates and times a true hell in C/C++ .... there are dozens of functions and structures to choose from, and the help leaves it up to you to figure out why you should choose one above the other.
int nWeeks = (int) (nDays / 7) + (nDays % 7);
~Lockias