| re: DatePart not returning name of month correctly
troddy wrote:[color=blue]
> I am using the DatePart funtion in a query to extract the day, month
> and year in separate fields in a query. The function works fine but I
> am only getting a number for the month even if the field type is a
> long date and the month is stored in the table. I tried the following
> to try and get the name of the month to work.
>
> DateTest: Format(DatePart("m",[DateAffirmed]),"mmmm")
>
> The DateAffirmed field had a date stored of 16/03/2006.
>
> the result gave me January even though the month is number 3. I then
> tried the following to test the format
>
> MarchDate: Format(3,"mmmm")
>
> This also returned January and when I test all the numbers from 1 - 12
> the only one that didn't come out as January was number 1 which came
> out as December.
>
> Any ideas?[/color]
Your logic is wrong. DatePart("m"...) wil return an integer and then you are
attempting to apply a date format to that integer. In other words the output of
DatePart is not an appropriate input to the Format() function when trying to
apply date formats.
As far as the Format function is concerned you are passing in the date
represented by the number 3 which is the 2nd of January 1900. Just use...
Format([DateAffirmed],"mmmm")
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com |