Hello,
I have a field in a table, the data type for this field is date/time, I have a query based on the table containing the field, I put month function to get the month of that field:
Month([ArrivalDate]) and it gave me the digit 2 because the date was 02/21/2017, so far it is correct; I wanted to get the Month name for 2 which is Feb; I used this function:
MonthName ( number, [abbreviate]), this is what I entered: New field: MonthName(Month([ArrivalDate]),True); when I get to this point, I get an error indicating data type mismatch.
What is the problem?
Regards,
orangeApple
Get the month name for a value of 1-12
-
- BronzeLounger
- Posts: 1498
- Joined: 01 Mar 2015, 02:03
-
- Administrator
- Posts: 78519
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Get the month name for a value of 1-12
Does your table contain empty (blank, null) arrival dates? That would cause a problem.
To get around it, you can use Format([ArrivalDate],"mmm")
This will return a blank if the arrival date is blank.
Or you could simply add the ArrivalDate field to the query and set the Format property of the ArrivalDate column to mmm.
To get around it, you can use Format([ArrivalDate],"mmm")
This will return a blank if the arrival date is blank.
Or you could simply add the ArrivalDate field to the query and set the Format property of the ArrivalDate column to mmm.
Best wishes,
Hans
Hans
-
- BronzeLounger
- Posts: 1498
- Joined: 01 Mar 2015, 02:03
Re: Get the month name for a value of 1-12
Hello Hans,
I used Format([ArrivalDate],"mmm") and it didn't work, it returned all as Jan. I used IIF() and it did work.
Thanks for it.
OrangeApple
I used Format([ArrivalDate],"mmm") and it didn't work, it returned all as Jan. I used IIF() and it did work.
Thanks for it.
OrangeApple
-
- Administrator
- Posts: 78519
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Get the month name for a value of 1-12
Format should work if ArrivalDate is a date/time field...
Best wishes,
Hans
Hans