Current month written out


G

gmbrant

I need to see the current month written out. When I use the formula below I
get the previous Month to the current one.

=Format(DateSerial(Year(Date()),Month(Date())-1,2),"mmmm")

When I take out the minus sign, it doesn't work. I have also tried the
following and it gives me January instead of the current month of July.

=Format(Month(Date()),"mmmm")

Please explain to me what I am doing wrong.

Thank you.
 
Ad

Advertisements

D

Douglas J. Steele

Crystal's given you the correct answer, but I thought I'd comment on your
first equation.

=Format(DateSerial(Year(Date()),Month(Date())-1,2),"mmmm")

If you used that today (30 July, 2008), it should return June. That's
because DateSerial takes three components (year, month and day) and creates
a date, which is this case would be 2 June, 2008. It uses today's Year
because of Year(Date()), last month because of Month(Date()) - 1 and a day
of 2. Note that the DateSerial function is smart enough to handle year-ends:
if you were to run that on 5 January, 2008, you'd end up with December,
since the DateSerial function would have returned 2 December, 2007.
 
G

gmbrant

Thank you for your explanation ... why .. when I take out the minus sign ..
it doesn't work. I expected it to give me the current date. I understand
that the minus would give me last month, but when the minus sign is removed,
I don't understand why it doesn't give me the current date.

Always appreciate your answers... thanks.
 
Ad

Advertisements

G

gmbrant

My whole message didn't show up in the last communication... so here it is
'hopefully'...

=Format(DateSerial(Year(Date()),Month(Date())1,2),"mmmm")

I get the following error message...The expression you entered contains
invalid syntax" "You may have used an operand without an operator"
 
J

John Spencer

You have a 1 in the second argument to DateSerial that should not be there.

=Format(DateSerial(Year(Date()),Month(Date()),2),"mmmm")

Why not use the following which is much simpler and should do the same
thing.

=Format(Date(),"mmmm")


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
G

gmbrant

John,

I did.. am .. using the more simpler script from Crystal, however, Doug was
helping me to understand 'why' the first one wouldn't work. Now I see why.

Thank you ... it appears that the syntax doesn't care what the day is based
 
Ad

Advertisements

S

strive4peace

you can use DateSerial when you are constructing a date... for instance,
here is how to get the last day of the current month:

=DateSerial( Year(Date), Month(Date)+1, 0)

because 1 is added to the month argument, it will consider next month

because each month starts with 1, 0 will be the last day of the previous
month -- which is the last day of the current month ;)

~~~
DateSerial is really quite cool ... you can do things like this:

=DateSerial( Year(Date), Month(Date), 1+45)
-- that will give you 45 days from the first day of the current month

DateSerial( Year(Date), Month(DOB), Day(DOB))
WHERE DOB is a field holding Date of Birth
tells you what day a birthday will fall on this year


Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
G

gmbrant

:) That is really cool, thanks!

A few examples with explanations goes a long way ... for me ;-)

Thank you ( to all ) ... because your time is valuable and I appreciate it.
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top