syntax for Week number

  • Thread starter Thread starter Revned
  • Start date Start date
R

Revned

Hi,

Can anyone help me how figure out a correct syntax for week no.

I have tblRev with fieldname:Date
I want access automatically display the week no. after
entering a Date in my field: Date.

Please can anyone help

Thanks
 
Hi,
With Monday as a first day of week following code should be helpful:

Format(Date, "ww",vbMonday)

Regards,
Sebastian
 
Hi,

Can anyone help me how figure out a correct syntax for week no.

I have tblRev with fieldname:Date
I want access automatically display the week no. after
entering a Date in my field: Date.

Please can anyone help

Thanks

First off... it's best to NOT use the reserved word Date as a fieldname!
Access can (and will!) get it confused with the builtin Date() function, and
give you strange errors.

That said, you can have a textbox on your form or report bound to the date
field, and set its Format property to "ww" to display the (1 to 54) week
number; for more control, you can use

=DatePart("ww", [datefield], <optional parameters>)

See the VBA help for DatePart; the parameters let you specify just what you
mean by the first week of the year (what day does the week start - Monday or
Sunday or some other day? Can the first week of the year be only one day long,
or should Week 1 be the week of the first Tuesday? etc.)
 
Thank you very much

John W. Vinson and sweet_dreams

I really appreciate

John W. Vinson said:
Hi,

Can anyone help me how figure out a correct syntax for week no.

I have tblRev with fieldname:Date
I want access automatically display the week no. after
entering a Date in my field: Date.

Please can anyone help

Thanks

First off... it's best to NOT use the reserved word Date as a fieldname!
Access can (and will!) get it confused with the builtin Date() function, and
give you strange errors.

That said, you can have a textbox on your form or report bound to the date
field, and set its Format property to "ww" to display the (1 to 54) week
number; for more control, you can use

=DatePart("ww", [datefield], <optional parameters>)

See the VBA help for DatePart; the parameters let you specify just what you
mean by the first week of the year (what day does the week start - Monday or
Sunday or some other day? Can the first week of the year be only one day long,
or should Week 1 be the week of the first Tuesday? etc.)
 
Back
Top