# Make Access show weekday name from date



## DKTaber (Oct 26, 2001)

I have a mental block and can't find anything in Functions help to help solve my SIMPLE problem. Have an Access 2000 database. Want to have a query expression return the DAY NAME (like Monday, Tuesday, Friday) from the full date. That is, an expression similar to function([eventdate]) that will return the day name. For instance, function([8/23/07]=Thursday. What function will do that?


----------



## OBP (Mar 8, 2005)

Weekday(Date, start of week) and WeekdayName.
The start of week is optional, you can specify when the week starts, the weekday returns a number, the weekdayName returns a day from a number.


----------



## OBP (Mar 8, 2005)

Like this 

Dim day As Integer
day = Weekday(Date, vbMonday)
MsgBox WeekdayName(day)


gives the name of today.


----------



## DKTaber (Oct 26, 2001)

OBP said:


> Like this
> 
> Dim day As Integer
> day = Weekday(Date, vbMonday)
> ...


I'm not doing this from a VBA module; it's something I want to put into a query as an expression. Can I use WeekdayName(Day([eventdate]))?


----------



## OBP (Mar 8, 2005)

Don, this works as a Query Heading

dayname: WeekdayName(Weekday([Date1],2))


----------



## finewine291 (Mar 2, 2007)

To Extract the day of the week you will need to build two expressions.
The first Expression in the query is to get the numerical value of the day of the week. The numerical value will be used in the second expression. My field that holds the date is named testdate. Here is the first expression:
Expr1: Day([Testdate]) This field does not need to be shown in the query results.

Now you need to build a second expression:
Expr2: WeekdayName([Expr1],0,4)

The name of the function is WeekdayName however it is not one of the easier funtions to use.

Hope this helped.

Jennifer


----------



## finewine291 (Mar 2, 2007)

Nice OBP - worked like a charm except I had to change the 2 to a 1 to get it to pull the correct day.
Thanks for the tip.

Jennifer


----------



## OBP (Mar 8, 2005)

Jennifer & Don, sorry about the number in the expression, I was thinking that it was still Thursday, but it was in fact after Midnight, so when it said Friday I adjusted it, I was more tired than I thought.


----------



## DKTaber (Oct 26, 2001)

OBP said:


> Don, this works as a Query Heading
> 
> dayname: WeekdayName(Weekday([Date1],2))


Worked perfectly (with the 1). What is the 1 or 2 or whatever at the end of the expression, anyway? Is that the way the function defines today; i.e., if I left made it 2, would everything be one day after what it's supposed to be?


----------



## finewine291 (Mar 2, 2007)

It represents the day of the week as a number. Sunday = 1 Monday=2 Tueday=3 etc. Some adjustment has to be made because the the weekday and what number it equals changes due to leap year and the such.

Please mark the thread as solved please.

Jennifer


----------



## DKTaber (Oct 26, 2001)

finewine291 said:


> It represents the day of the week as a number. Sunday = 1 Monday=2 Tueday=3 etc. Some adjustment has to be made because the the weekday and what number it equals changes due to leap year and the such.
> 
> Please mark the thread as solved please.
> 
> Jennifer


Well, that doesn't make sense to me. I ran the expression today, Friday, which according to your message should be 6. I used 1 and it produced the correct days from the full date. ???


----------



## finewine291 (Mar 2, 2007)

My numbers may not be exact and I am not exactly sure how MS set that up. If you would like to know more about that function here is the link:

http://office.microsoft.com/en-us/access/HA012289341033.aspx?pid=CH100728911033

Jennifer


----------



## DKTaber (Oct 26, 2001)

finewine291 said:


> My numbers may not be exact and I am not exactly sure how MS set that up. If you would like to know more about that function here is the link:
> 
> http://office.microsoft.com/en-us/access/HA012289341033.aspx?pid=CH100728911033


Thanks. Checked out the link. It explains what the number at the end of the expression is (first day of week, 1 = Sunday, the default), but also contained an optional Boolean function that abbreviates the day. Haven't tried it, but assume it means that if you enter a 3 before the 1, it returns the 3-letter abbreviation of the day. E.g., WeekdayName([date],3,1) for a Wednesday date would return "Wed". The MS page did NOT provide an example, which would have clarified this. Typical of MS -- half answers.


----------

