week number HELP

  • Thread starter Thread starter Art Vandaley
  • Start date Start date
A

Art Vandaley

Hi,

In access 2007 Beta I have following problem:

text1.value = calendar1.value (text1's format is "ww")

text1 returns 53 for the date of 29.12.2006. Normally it must be 52

How can I fix this problem?

How can I use "firstweekof year" ?

PS: "Format(expression[, format[, firstdayofweek[, firstweekofyear]]])"
means nothing to me. I need more explanation. Where should I put the format
VB or properties?

Thanks a lot for your help in advance..
 
Try using this function instead:

Public Function WeekNum(dt As Date) As Variant
Dim wn As Variant
Dim period As Date
Dim yr As Long
Dim mth As Integer

yr = Year(dt)
mth = Month(dt)

If mth < 7 Then yr = yr - 1
period = "01-07-" & Format(yr, "####")

wn = DateDiff("ww", period, dt)

WeekNum = Format(Abs(wn) + 1, "00")
End Function

You may need to change the line:

period = "01-07-" & Format(yr, "####")

to:

period = "07-01-" & Format(yr, "####")

because of you regional settings.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

week number SOS 3
Week numbers problem 1
Week number 1
datepart returns erroneous week number? 2
Return week number 11
Week Number 2
Wrong week number 2
Week numbers 2

Back
Top