6 Replies Latest reply on May 31, 2010 12:00 AM by AHBentsen

# Number of Week

Hi
I would want to create an application type calendar, in which to be visualized the days, are visualized further also the number of the week of the year. In SQL or other similar languages, there is the possibility to plan as format date WW, that returns the number of the week departing from a date (ex. 27/05/2010 correspond to week 21).

Thanks
Andrea

• ###### 1. Re: Number of Week

Hi,

We can calculate the number of week, just by knowing the number of days and just divide that by 7.... u will be able to calculate the weeks.

What I want to say is suppose user enter 2/27/2010 i.e 2nd february 2010..... from this we will be able to calculate the number of days till 2nd february 2010. suppose it come out to be 45 days ..........when we will divide 45/7 = 6 so it can it calcualted the weeks of the year can be known....

• ###### 2. Re: Number of Week

I had also thought so, but if then I go to check indeed on the calendar, the week n. 6 are that that begins 8/02/2010 and it ends 13/2/2010. There is then something that doesn't square.. because it needs besides to remember whether to have the 52 weeks a year, if the first week of the year not inzia with Monday is counted as week 0 rather than week 1.

• ###### 3. Re: Number of Week

Take a look at the DateUtils library (  http://flexdateutils.riaforge.org/ ); it should have methods to get you  the week of the year.

If not, drop me a line  privately; because I wrote a lot of new methods to that class for the  Flextras Calendar.  I just haven't gotten around to donating them back  to the project yet.

And I'll add; if you want to create a Calendar Application; be sure to check out our Calendar Component.  I'm sure it'll save you tons of time.

http://www.flextras.com/?event=ProductHome&productID=15

• ###### 4. Re: Number of Week

First week of the year will be 1 january YEAR no matter what. Create a new Date object with 1 january and the current year.

Make a difference with the current time ( new Date().time ) and divide by WEEK_IN_MS.

Is this enough for you ?

• ###### 5. Re: Number of Week

Thanks to all!!! Now I try!

• ###### 6. Re: Number of Week

Hi all

The week number for 1. January this year is 53, and here is how to calculate it:

http://en.wikipedia.org/wiki/Seven-day_week#Week_numbering

Hope this helps

Allan