Converting a date to a numeric (1-7 number) day of the week

J

John_

I am trying to take a date (e.g., 01/01/2008) and have Access tell me the
numeric day of the week (1-7) that corresponds to each date in a table.
Thanks for your help!
 
F

fredg

I am trying to take a date (e.g., 01/01/2008) and have Access tell me the
numeric day of the week (1-7) that corresponds to each date in a table.
Thanks for your help!

Look up the DatePart and the Weekday functions in VBA help.
=DatePart("w", [DateField])
will return 4 if the day is a Wednesday.
or...
You can also use the Weekday function
=WeekDay([DateField])
will return a 4 if the day is Wednesday.
 
J

John W. Vinson

I am trying to take a date (e.g., 01/01/2008) and have Access tell me the
numeric day of the week (1-7) that corresponds to each date in a table.
Thanks for your help!

Put a calculated field in the query:

DayOfWeek: Weekday([datefield])

By default Sunday is 1, Saturday is 7; see the VBA Help for Weekday if you'ld
like to change that convention.

John W. Vinson [MVP]
 
J

John_

That worked great! Thanks!

fredg said:
I am trying to take a date (e.g., 01/01/2008) and have Access tell me the
numeric day of the week (1-7) that corresponds to each date in a table.
Thanks for your help!

Look up the DatePart and the Weekday functions in VBA help.
=DatePart("w", [DateField])
will return 4 if the day is a Wednesday.
or...
You can also use the Weekday function
=WeekDay([DateField])
will return a 4 if the day is Wednesday.
 
J

John_

Thanks so much. That was very helpful!

John W. Vinson said:
I am trying to take a date (e.g., 01/01/2008) and have Access tell me the
numeric day of the week (1-7) that corresponds to each date in a table.
Thanks for your help!

Put a calculated field in the query:

DayOfWeek: Weekday([datefield])

By default Sunday is 1, Saturday is 7; see the VBA Help for Weekday if you'ld
like to change that convention.

John W. Vinson [MVP]
 

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