Expressions

  • Thread starter Thread starter k.roberts
  • Start date Start date
K

k.roberts

I am using =DatePart("yyyy", [OrderDate]) to pull through the month
displayed as mmmm format, from a field containing a date in ddd
d-mmm-yy format. I am getting an error back - #Error. Can anyone tell
me why?
 
Is OrderDate a datetime field or is it a text field? If OrderDate is a
DateTime field then you should not be having a problem.

Access will do its best to return the YEAR (YYYY) if OrderDate contains a
string it can convert to a date.
It cannot convert "Wed 30 November 2005" but it can convert "30 November
2005".
 
I am using =DatePart("yyyy", [OrderDate]) to pull through the month
displayed as mmmm format, from a field containing a date in ddd
d-mmm-yy format. I am getting an error back - #Error. Can anyone tell
me why?

DatePart("yyyy",[OrderDate]) will return the year of the order, i.e.
2005, not the month.

That will not cause an error in and of itself.
Are you trying to then format 2005 as a month?
Any value of 2005, formatted as mmmm, will be displayed as 'June'.

Perhaps the #Error is caused by the control being named "OrderDate".
Change the control name to something else.
 
This fiunction returns a variant, is that what you are using? The other
possibility is that [OrderDate] does not exist or contains a date in an
unrecognized format . Did you try control-break and then examine the contents
of [orderdate]? You may have to reformat [orderdate] to a recognized format.

Dorian
 
K.roberts,

Where are you using that expression? What does "pull through" mean?
How are you trying to make it display as mmmm format? It is hard to see
what you mean, since you are using the year portion of a date, and...
then you want it to display as a month? If you are using the Format
property of a textbox to set the display as mmmm then this won't work
unless it is a date that you are formatting, which is not the case here
as your expression will return a non-date value. Maybe you need one of
these approaches?...
- Set the Control Source of a textbox to...
=Format([Order Date],"mmmm")
- Set the Control Souirce of a textbox to...
=[Order Date]
.... and then set its Format property to mmmm
 
Back
Top