Day of week

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

I have a field that contains the days Monday to Sunday, Weekdays. Is there a
function that would make Monday = 1. Of course I'll need a filter to exclude
"weekdays".

Other than a case else checking for every day.

Thanks,
J.
 
The DatePart function can return a number from 1 to 7, representing each day
of the week, based on the actual date that you give to the function. And it
has an argument to set which day is 1 (e.g., Sunday, or Monday, or...).

Not knowing what type of data you have in the field, it's difficult to give
a specific example of how DatePart function might be useful to you, if at
all. Give us more information and we can provide better suggestions.
 
I added a field to the table that contains the data for the drop down list
and put the number beside them then linked this table with the data table
and used that field for sorting instead of the day name.
 
= datepart(,datetxt,2)
Ken Snell MVP said:
The DatePart function can return a number from 1 to 7, representing each
day of the week, based on the actual date that you give to the function.
And it has an argument to set which day is 1 (e.g., Sunday, or Monday,
or...).

Not knowing what type of data you have in the field, it's difficult to
give a specific example of how DatePart function might be useful to you,
if at all. Give us more information and we can provide better suggestions.
--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
 
The field only contains the words (Monday etc)
Ken Snell MVP said:
The DatePart function can return a number from 1 to 7, representing each
day of the week, based on the actual date that you give to the function.
And it has an argument to set which day is 1 (e.g., Sunday, or Monday,
or...).

Not knowing what type of data you have in the field, it's difficult to
give a specific example of how DatePart function might be useful to you,
if at all. Give us more information and we can provide better suggestions.
--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
 
I'd use the Switch function, then:

DayNumberField: Switch("Monday", 1, "Tuesday", 2, "Wednesday", 3,
"Thursday", 4, "Friday", 5, "Saturday", 6, "Sunday", 7)
 
I think that needs to be:

DayNumberField: Switch([FieldName] = "Monday", 1, [FieldName] = "Tuesday",
2, [FieldName] = "Wednesday", 3, [FieldName] = "Thursday", 4, [FieldName] =
"Friday", 5, [FieldName] = "Saturday", 6, [FieldName] = "Sunday", 7)

(replace [FieldName] with the name of the appropriate field)
 
<sigh > It's been a long week.... Thanks for the correction, Doug!

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Douglas J. Steele said:
I think that needs to be:

DayNumberField: Switch([FieldName] = "Monday", 1, [FieldName] = "Tuesday",
2, [FieldName] = "Wednesday", 3, [FieldName] = "Thursday", 4, [FieldName]
= "Friday", 5, [FieldName] = "Saturday", 6, [FieldName] = "Sunday", 7)

(replace [FieldName] with the name of the appropriate field)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ken Snell MVP said:
I'd use the Switch function, then:

DayNumberField: Switch("Monday", 1, "Tuesday", 2, "Wednesday", 3,
"Thursday", 4, "Friday", 5, "Saturday", 6, "Sunday", 7)

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
 
Back
Top