Week-Number of a given Time.

I need a function that does something like

UINT WeekNumber(SYSTEMTIME st)

of course i could programm it, but i know there are some region-
specific rules (when does a week starts, what is the defined 1st week
of the year) and there is also a ISO-standard covering this, but much
more important: it is already coded ... CMonthCalCtrl uses it and its
already implemented in every windows system that has the control.

Does anyone by chance know what function to use, where it is defined
and how to call it?
Does anyone has the sourcecode of MonthCalCtrl32 *g*?

TIA, rhavin;)

0
clqrq (258)
10/9/2007 5:26:29 PM
vc.mfc 33608 articles. 0 followers. Follow

5 Replies
686 Views

Similar Articles

[PageSpeed] 46

I don't think there is one, but you could write one pretty easily.

All you have to do is get the date of the year, 
COleDateTime::GetDayOfYear(), and divide by 7.
Don't forget to account for partial week at the beginning of year.

AliR.

".rhavin grobert" <clqrq@yahoo.de> wrote in message 
news:1191950789.745822.323770@k79g2000hse.googlegroups.com...
>I need a function that does something like
>
> UINT WeekNumber(SYSTEMTIME st)
>
> of course i could programm it, but i know there are some region-
> specific rules (when does a week starts, what is the defined 1st week
> of the year) and there is also a ISO-standard covering this, but much
> more important: it is already coded ... CMonthCalCtrl uses it and its
> already implemented in every windows system that has the control.
>
> Does anyone by chance know what function to use, where it is defined
> and how to call it?
> Does anyone has the sourcecode of MonthCalCtrl32 *g*?
>
> TIA, rhavin;)
> 


0
AliR3470 (3235)
10/9/2007 7:09:47 PM
On 9 Okt., 21:09, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
> ".rhavin grobert" <cl...@yahoo.de> wrote in message
>
> news:1191950789.745822.323770@k79g2000hse.googlegroups.com...
>
> >I need a function that does something like
>
> > UINT WeekNumber(SYSTEMTIME st)
>
> > of course i could programm it, but i know there are some region-
> > specific rules (when does a week starts, what is the defined 1st week
> > of the year) and there is also a ISO-standard covering this, but much
> > more important: it is already coded ... CMonthCalCtrl uses it and its
> > already implemented in every windows system that has the control.
>
> > Does anyone by chance know what function to use, where it is defined
> > and how to call it?
> > Does anyone has the sourcecode of MonthCalCtrl32 *g*?
>
> > TIA, rhavin;)
>
> I don't think there is one, but you could write one pretty easily.
>
> All you have to do is get the date of the year,
> COleDateTime::GetDayOfYear(), and divide by 7.
> Don't forget to account for partial week at the beginning of year.
>
> AliR.
>

That's the problem: In some regions, you have Weekstart = Monday, in
others Sunday, i think in Israel it's Saturday and the definition
(what week is the first of the Year) are also different. That is all
already coded in windows, so i thought it is somewhere accessible.

0
clqrq (258)
10/9/2007 7:25:01 PM
It is available in .Net, haven't seen anything in SDK or MFC.

I found this here: 
http://www.codeproject.com/ce/cdatetimeformat.asp?df=100&forumid=14366&exp=0&select=1414613

int CDateTime::GetWeekOfYear()
{
CDateTime Jan1stNxtYear( GetYear()+1, 01, 01, 00, 00, 00 );
CDateTime odt1stDay1stWeekNextYear = Jan1stNxtYear.GetDate1stDay1stWeek();
CDateTime odt1stDay1stWeek = GetDate1stDay1stWeek();
COleDateTimeSpan span, span1Day(1,0,0,0);

int nWeek(-1);

if ( odt1stDay1stWeek > (*this) )
{
CDateTime newYearsEve( GetYear() - 1, 12, 31, 00, 00, 00 );
nWeek = newYearsEve.GetWeekOfYear();
} else if ( odt1stDay1stWeekNextYear <= (*this) ) //we're in week 1.
{
nWeek = 1;
} else
{
span = (*this) - odt1stDay1stWeek; // find the span in days between (1day of 
1st week) and current day.
nWeek = ( (span.GetDays() / 7) +1);
}
return nWeek;
}

AliR.


".rhavin grobert" <clqrq@yahoo.de> wrote in message 
news:1191957901.470541.185060@57g2000hsv.googlegroups.com...
> On 9 Okt., 21:09, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
>> ".rhavin grobert" <cl...@yahoo.de> wrote in message
>>
>> news:1191950789.745822.323770@k79g2000hse.googlegroups.com...
>>
>> >I need a function that does something like
>>
>> > UINT WeekNumber(SYSTEMTIME st)
>>
>> > of course i could programm it, but i know there are some region-
>> > specific rules (when does a week starts, what is the defined 1st week
>> > of the year) and there is also a ISO-standard covering this, but much
>> > more important: it is already coded ... CMonthCalCtrl uses it and its
>> > already implemented in every windows system that has the control.
>>
>> > Does anyone by chance know what function to use, where it is defined
>> > and how to call it?
>> > Does anyone has the sourcecode of MonthCalCtrl32 *g*?
>>
>> > TIA, rhavin;)
>>
>> I don't think there is one, but you could write one pretty easily.
>>
>> All you have to do is get the date of the year,
>> COleDateTime::GetDayOfYear(), and divide by 7.
>> Don't forget to account for partial week at the beginning of year.
>>
>> AliR.
>>
>
> That's the problem: In some regions, you have Weekstart = Monday, in
> others Sunday, i think in Israel it's Saturday and the definition
> (what week is the first of the Year) are also different. That is all
> already coded in windows, so i thought it is somewhere accessible.
> 


0
AliR3470 (3235)
10/9/2007 7:52:57 PM
The following code will tell you what day is the first day of the week:

// LOCALE_IFIRSTDAYOFWEEK
DWORD ifirstdayofweek_data;
LCID lcid = LOCALE_SYSTEM_DEFAULT;
VERIFY(::GetLocaleInfo(lcid, LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER,
(LPTSTR)&ifirstdayofweek_data, sizeof(DWORD)));
// ... use ifirstdayofweek_data here

For US, the value is 6, but the day name would be LOCALE_SDAYNAME7 (see the documentation
of GetLocaleInfo)


Unfortunately, when I select Hebrew as the language and ask for LOCALE_SDAYNAME6 in my
Locale Explorer, I get the Hebrew characters for the day name, and I can't read it.  It
sort of looks like this (depending on the font you use for your newsgroup reader, this may
or may not be readable)

********   *****    *  *     *
  *        *        *    *  *     *
  *        *        *    ***     *
  *        *        *    *        *
**        *  *******   *****

but I don't know if selecting the Hebrew locale on a US machine will return the days based
on the US calendar or not

You can download my Locale Explorer from my MVP Tips site.  It generates the code to do
the retrieval.
					joe



On Tue, 09 Oct 2007 12:25:01 -0700, ".rhavin grobert" <clqrq@yahoo.de> wrote:

>On 9 Okt., 21:09, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
>> ".rhavin grobert" <cl...@yahoo.de> wrote in message
>>
>> news:1191950789.745822.323770@k79g2000hse.googlegroups.com...
>>
>> >I need a function that does something like
>>
>> > UINT WeekNumber(SYSTEMTIME st)
>>
>> > of course i could programm it, but i know there are some region-
>> > specific rules (when does a week starts, what is the defined 1st week
>> > of the year) and there is also a ISO-standard covering this, but much
>> > more important: it is already coded ... CMonthCalCtrl uses it and its
>> > already implemented in every windows system that has the control.
>>
>> > Does anyone by chance know what function to use, where it is defined
>> > and how to call it?
>> > Does anyone has the sourcecode of MonthCalCtrl32 *g*?
>>
>> > TIA, rhavin;)
>>
>> I don't think there is one, but you could write one pretty easily.
>>
>> All you have to do is get the date of the year,
>> COleDateTime::GetDayOfYear(), and divide by 7.
>> Don't forget to account for partial week at the beginning of year.
>>
>> AliR.
>>
>
>That's the problem: In some regions, you have Weekstart = Monday, in
>others Sunday, i think in Israel it's Saturday and the definition
>(what week is the first of the Year) are also different. That is all
>already coded in windows, so i thought it is somewhere accessible.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
10/10/2007 2:52:57 AM
On 10 Okt., 04:52, Joseph M. Newcomer <newco...@flounder.com> wrote:
> The following code will tell you what day is the first day of the week:
>
> // LOCALE_IFIRSTDAYOFWEEK
> DWORD ifirstdayofweek_data;
> LCID lcid = LOCALE_SYSTEM_DEFAULT;
> VERIFY(::GetLocaleInfo(lcid, LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER,
> (LPTSTR)&ifirstdayofweek_data, sizeof(DWORD)));
> // ... use ifirstdayofweek_data here
>
> For US, the value is 6, but the day name would be LOCALE_SDAYNAME7 (see the documentation
> of GetLocaleInfo)
>
> Unfortunately, when I select Hebrew as the language and ask for LOCALE_SDAYNAME6 in my
> Locale Explorer, I get the Hebrew characters for the day name, and I can't read it.  It
> sort of looks like this (depending on the font you use for your newsgroup reader, this may
> or may not be readable)
>
> ********   *****    *  *     *
>   *        *        *    *  *     *
>   *        *        *    ***     *
>   *        *        *    *        *
> **        *  *******   *****
>
> but I don't know if selecting the Hebrew locale on a US machine will return the days based
> on the US calendar or not
>
> You can download my Locale Explorer from my MVP Tips site.  It generates the code to do
> the retrieval.
>                                         joe
>
>
>
>
>
> On Tue, 09 Oct 2007 12:25:01 -0700, ".rhavin grobert" <cl...@yahoo.de> wrote:
> >On 9 Okt., 21:09, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
> >> ".rhavin grobert" <cl...@yahoo.de> wrote in message
>
> >>news:1191950789.745822.323770@k79g2000hse.googlegroups.com...
>
> >> >I need a function that does something like
>
> >> > UINT WeekNumber(SYSTEMTIME st)
>
> >> > of course i could programm it, but i know there are some region-
> >> > specific rules (when does a week starts, what is the defined 1st week
> >> > of the year) and there is also a ISO-standard covering this, but much
> >> > more important: it is already coded ... CMonthCalCtrl uses it and its
> >> > already implemented in every windows system that has the control.
>
> >> > Does anyone by chance know what function to use, where it is defined
> >> > and how to call it?
> >> > Does anyone has the sourcecode of MonthCalCtrl32 *g*?
>
> >> > TIA, rhavin;)
>
> >> I don't think there is one, but you could write one pretty easily.
>
> >> All you have to do is get the date of the year,
> >> COleDateTime::GetDayOfYear(), and divide by 7.
> >> Don't forget to account for partial week at the beginning of year.
>
> >> AliR.
>
> >That's the problem: In some regions, you have Weekstart = Monday, in
> >others Sunday, i think in Israel it's Saturday and the definition
> >(what week is the first of the Year) are also different. That is all
> >already coded in windows, so i thought it is somewhere accessible.
>
> Joseph M. Newcomer [MVP]
> email: newco...@flounder.com
> Web:http://www.flounder.com
> MVP Tips:http://www.flounder.com/mvp_tips.htm- Zitierten Text ausblenden -
>
together with what i already programmed it should do the trick ...
thank thee!

0
clqrq (258)
10/10/2007 2:29:17 PM
Reply:

Similar Artilces:

printing checks with account name and number
I can not seem to figure out how to print checks and have the account name, number and the bank it is drawn on printed on the check. HELP! See http://umpmfaq.info/faqdb.php?q=39. "Lynn" <lwalk3@hotmail.com> wrote in message news:3b5f01c4729c$e2f554d0$a401280a@phx.gbl... > I can not seem to figure out how to print checks and have > the account name, number and the bank it is drawn on > printed on the check. > HELP! ...

Summing weekly values to fall into correct month
Hi, Could someone please help me with this . My spreadsheet has row data in weekly buckets . I would like these weekly amounts to be summed to form the corressponding monthly total . However , some weeks are split across 2 months. For e.g. w/c 28/06/10 has 3 days that fall into June and 4 days that fall into July. 1) How do I get excel to add up all the weeks in June, and for this particular week, instead of taking the full weekly value into June , calculate the value/7 * 3 days ? 2) How do I get the following month of July to also add in the value/7*4 days from this week...

tracking time
greetings all, I have a file where i am tracking time. periodically a new line is added with the new time. for reason difficult to explain, periodically, the time gets reset to zero i.e. starts over. currently i am using format dd:hh:mm:ss this works well but occasionally the time runs beyond 30 days(1 month) and the above format resets to day 1 when it goes beyond 30 day(1 month?). i have tried dilffernts format to try and make the days roll over ie 35:00:00:00 but to no avail. [dd]:hh:mm:ss doesn't work. can someone give me some pointers/tips/directions on my dilima. he...

Find emails in Finder using Time Machine?
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Email Client: Exchange Hi- <br><br>I apologize but I really don't understand Entourage so bear with me. I had to erase and install everything on my Mac. I have many Time Machine backups of my Mac. I reinstalled Entourage 2008 and got it working with Exchange with no problems. What I am missing are the emails that did NOT sit on the Exchange server but rather were on my hard drive. Please tell me where (in my Time Machine backups) are the local emails located so I can drag them to *same* folder on my...

Deleteing Part numbers
Does any body know how to delete a part number that has history. I have been told that you cannot delete any part number that any history. As far as anyone knows in my department it cannot be done. You have to remove history for that item before you delete it. Utils->Inventory. "James Rodgers" wrote: > Does any body know how to delete a part number that has history. I have been > told that you cannot delete any part number that any history. As far as > anyone knows in my department it cannot be done. ...

Number Format #13
How to format say 123456789 in the format 12,34,56,789. This particula number format is being used in India. (grouping of 2 digits rather tha 3 excluding the last 3 digits -- harikris ----------------------------------------------------------------------- harikrish's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2710 View this thread: http://www.excelforum.com/showthread.php?threadid=46647 What version of Excel. In Excel XP see function BhatText as in Thai Bhat currency. =BAHTTEXT(A37) If you just have positive numbers you can use as custom format like: [&g...

summerizing formula for weekly lesson plans
Hi, This is a request from a primary school headteacher and a good friend of mine. They use an excel sheet that shows the lesson plan for each teacher. Nothing special on it. But lately they needed some summerizing figures on the sheets. For each teacher, there are "names" in the region G10:K19 in its excel sheet. The names includes a part consisting of the "lesson name" itself and a part consisting the "class" that'l take it (For example "ScienceA1"). Thus the "name" data can easily be seperated because the "lesson name" is at th...

variable number formats
How can I format a set of cells to dispaly varying decimal place depending on a value in a different cell. e.g., if "A5" < 1 then format cells G10:G20 to five decimal places, if "A5" < 10 then format cells G10:G20 to four decimal places, if "A5" < 50 then fomat cells G10:G20 to three decimal places, if "A5" < 100 then format cells G10:G20 to two decimal places, if "A5" < 500 then format cells G10:G20 to one decimal place. I have used the function, Round(num,x) but this does not do the tric most of the time. It does not dis...

Non Sequential Serial Number from Excel
How can i use or modify a macro that will read from an excel file during Serial Number creation using the Serial Number Insert Window in Receiving and Inventory Transaction Adjustment Serial Number Insert window. Any help is greatly appreciated. You may want to look at Binary Stream's Serial Lot Copy&Paste Manager module. -- Charles Allen, MVP "esage" wrote: > How can i use or modify a macro that will read from an excel file during > Serial Number creation using the Serial Number Insert Window in Receiving and > Inventory Transaction Adjustment Serial N...

Format cells for time #2
I want to be able to format ceels for time BUT I don't want it to be "clock based," i.e. I want Excel to recognize 2:45 as 2 min. and 45 sec., not 2:45 AM. I have tired all of the formats that Excel offers under "Format Cell," but no luck. Any ideas? Thanks! Josh, Format/Cells/Number/Custom m "min "ss "sec" John "Josh k" <anonymous@discussions.microsoft.com> wrote in message news:002301c3d15d$0c78c170$a501280a@phx.gbl... > I want to be able to format ceels for time BUT I don't > want it to be "clock based,"...

Weeks
Hello everyone, I am trying to work with date. I want to see in a cell the week numbe with the stating date of that week and the ending date of thta week Example: Week #1 - 01 jan 2004 to 03 jan 2004 Week #2 - 04 jan 2004 to 10 jan 2004 Week #3 - 11 jan 2004 to 17 jan 2004 end so on. Can anyone help me. vru -- Message posted from http://www.ExcelForum.com Hi With the assumption that you store the weeknumber in column A and use the ISO definition for weeknumbers (Have a look at http://www.cpearson.com/excel/weeknum.htm for more information on this topic) use the following: 1. To calc...

Formula to see if a number is allocated
I need to find out if a number is allocated or free. Basically on sheet1 is a load of information. in Column G on this sheet is a unique identifier number. In sheet2 I have a list of numbers say from 1-100 which correspond to the identifier numbers in sheet1. Id like a forumla something like: "If A1 in sheet 2 = any number in column G in sheet1, then print Allocated, else print free" At the moment I have: =IF(A1=Sheet1!G:G,"allocated", "free") But it does not work. What it is doing is If A1 = everything in column G then say allocated, else say fre...

row number in Excel
Hi, I am using ODBC to connect to an Excel database, does anyone know of a function that I can use to select from row 50 to 100 of a spreadsheet. So, is it possible to use an sql statement on Excel database to get a range of rows? Does Excel have a row number function? Thanks Feng ...

How can I match numbers from two columns?
I have two columns with numbers. Some numbers are in both columns, some not. What I need to get is some formula that can compare both columns and tell me wich numbers are already in column 1 and what numbers are not. Something like this: 234 222 It's not in column A 444 300 Yes, it's in column A 300 150 It's not in column A I'll appreciate any help! One way assuming the list you want to check is in column B starting in row 1, in C1 enter the formula: =IF(ISNA(VLOOKUP(B1,A:A,1,0)),"It's not in Column A","Yes, it's in column A&q...

BKF-Display Results (a number) on form from a query
Example: I have a query that will count all Active Customers based off Account Numbers (unique). The query when run will obviouslly give me a count but can I get that count to display on my form so that I can always see a count as customers are added and deleted. E.g. 100 displays as current 101 diaplays when I add a customer 99 Displays if I remove a customer Thanks ...

Calculate the beginning of the week
I want to have a field in excel that gives me the "week of" date. For example, today is 4/25/06. The field would show the "week of" 4/23/06 because that is the date of last Sunday. I want it to automatically calculate the 'week of' data from today's date. Is this possible? If so, how do I do it. Thanks, Jasper Hi Jasper, =A1-WEEKDAY(A1)+1 -- Kind regards, Niek Otten "Jaz" <jrecto99@yahoo.com> wrote in message news:O2Yi5wHaGHA.4116@TK2MSFTNGP05.phx.gbl... |I want to have a field in excel that gives me the "week of" date. | ...

Time question
When I receive e-mail the timeis an hour behind. How do I change that. I know it has to do with Outlook itself and not my computer. I have Outlook2000. Thanks, J Are you using an exchange server or internet mail? and did you check you system time to make sur it was correct? If its internet mail it could be your providers email server. is it just you or other people in the office? JT ...

Budget weekly total don't add up
When setting up my budget, I set my income as a weekly amount but the total doesn't add up to the four weekly amounts. What is causing the problem? Try weekly * 52 wks/yr / 12 months/yr. There are more than four weeks per month. "DJ" <don777@twcny.rr.com> wrote in message news:117d01c37eeb$56e57b00$a001280a@phx.gbl... > When setting up my budget, I set my income as a weekly > amount but the total doesn't add up to the four weekly > amounts. > > What is causing the problem? ...

Auto number items
I am looking to put a number in a all of the different types of boxes on my diagram. I have been creating a text box with a number and dragging it to the box. I was in hopes that there might be an automated process. Thanks Chip Asmus Have you tried Tools/Addons/Visio Extras/Number Shapes... "Chip Asmus" <Chip@lawlershallmark.com> wrote in message news:eaZ0rwfYHHA.1244@TK2MSFTNGP04.phx.gbl... >I am looking to put a number in a all of the different types of boxes on my >diagram. I have been creating a text box with a number and dragging it to >the box. I ...

Wrong numbers on axes
I have encountered some strange numbering problems on graphs in a number of my files. The x axis time values: 1 2 3 4 5 6 7 8 9 10 11 12 13 are appearing in some graphs as 1 2 3 4 5 6 7 8 9 1 1 1 1 All the graphs's axes label source is the same set of cells. Changing the cells to different ones makes no difference, the difference seems to be in each graph's settings. In some other graphs I am getting a similar problem, the numbers 1-31 having the 20s appear as 2s. Interestingly if the axes is formatted as a number to 2 decimal places (in the faulty graphs) you end up w...

Maximum number of stores for E2K Enterprise
We're having a disagreement here! What is the maximum number of stores supported for a single Exchange 2000 Enterprise server? 16 or 20? If you can help me out with a technet link that would be awesome! Thanks!!!! http://www.microsoft.com/exchange/evaluation/editions.mspx Four storage groups; 5 databases per. (Total: 20 databases) -- Aloha, -Ben- Ben M. Schorr, OneNote-MVP Roland Schorr & Tower http://www.rolandschorr.com Microsoft OneNote FAQ: http://www.factplace.com/onenotefaq.htm **I apologize but I am unable to respond to direct requests for assistance. Please post q...

extracting numbers and adding
Using XL2002 for Windows, I want to extract and add numbers from cells. for example, let the following 3 lines each represent 1 cell. D2K13 V0F4 Y2 H4T10 How can I extract the numbers then add them. For example... D2K13 V0F4 = 2+13+0+4 = 19 Y2 = 2 H10T4 = 10+4 = 14 Is this possible? thanks, Tonso You could set up a User Defined Function to replace all characters with a + in the string, and then pass this to the Evaluate function. If you are likely to have two or more letters next to each other then the UDF would have to detect for this. I'm about to go out now - I'm...

Graph: number of curves
What is the maximum number of curves (series) in a graph ? A.B. In article <79axf.14930$W03.497734@news20.bellglobal.com>, abacga@sympatico.ca says... > What is the maximum number of curves (series) in a graph ? > > A.B. > > > Check XL help for 'Excel specifications and limits' (w/o the quotes). It contains a section on 'Charting specifications' -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions Hi, Charting limits are, Data series in one chart 255. Data p...

Charting with concatenated numbers and text
I am scatter charting from columns of data (text and numbers) that I concatanate into a long string so that I can use the validate drop down list feature in Excel, which only supports one column. I use Mid, Left and Right functions to then pick the relevant charting data from the string. Unfortunately although the numbers look good, Excel does not treat them the same way that it does with directly entered numbers - and my charts do not display accurately. Any ideas to to fix this problem or suggest a modified workflow. I am not an advanced user but would like to use the drop down li...

TTGErrors Number: 430
I've installed a VB6 application that I developed in a workstation that is using great plains. Now, when they run Great Plains and go to Tools, Integration an Internal Error in TTGErrors occur. The details of the error: Source: TTGErrors Message: Class does not support Automation or does not support expected interface Number: 430 Call Stack: IMProviderMain.NewConnection IMProviderMain.Connection IMProviderMain.main I checked the current MDAC version isntalled on this workstation which is MDAC2.7 SP1 Refresh. Is this error being caused by the MDAC version? How can I resolve this...