syntax for Week number

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
 
S

sweet_dreams

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

Format(Date, "ww",vbMonday)

Regards,
Sebastian
 
J

John W. Vinson

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.)
 
R

Revned

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.)
 

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

Top