Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format and Display month in Header 1

Status
Not open for further replies.

ThePixelMines

Technical User
Jun 6, 2007
17
US
I've created a monthly summary report to summarize my invoices. It's based on a date range. I want a header that displays the month and year based on the [End Date] of the requested date range. For the sake of this example imagine I'm using the date range of 4/1/2007 to 4/30/2007. To do so I wrote:
Code:
=DatePart("m",[End Date]) & " " & DatePart("yyyy",[EndDate]) & " Summary"
This returns 4 2007 Summary which is pretty close, but I don't want "4" I want "April." So, I added Format:
Code:
=Format(DatePart("m",[End Date]),"mmmm") & " " & DatePart("yyyy",[EndDate]) & " Summary"
This is the kicker. When I add the 'Format' I get back January 2007 Summary! What? Why January? No matter what the date range I still get January.

Please...Gurus of Tek-Tips...impart your wisdom upon me.

Thanks in advance.

Check it, Fool!
 
Why not simply this ?
=Format([End Date], "mmmm yyyy") & " Summary"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Well, thank you kindly, PHV. That indeed did the trick. I had derived the aforementioned code from the help files which (as I'm sure we're all well aware) are not very clear. Dare I say, convoluted.

Now, just out of curiosity, does anyone know why my previous attempts were yielding a "January" response?

Thanks!

Check it, Fool!
 
Just because DatePart("m",#2007-04-30#) is 1900-01-03

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top