Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Calculating number of weeks for current month

I know this must be a simple task but I am pulling my hair out trying to figure it out!

I am writing a monthly invoice report on invoice date for the current month. I have grouped on invoice date per week, however rather than show the invoice date I would like to show 'Week #: 1', 'Week#: 2', etc.

I have only been able to come up with the week number for the year...how do I tweak this formula?

DatePart("ww", DateAdd("d", -1, {TableName.DateField}))

Thanks for any help you can provide!

Marlene Allen

Crystal Reports 2008

CR Developer

Version 12.3.0.601

Product Type: FULL

Former Member
Former Member replied

Try it like this...

DatePart("ww", {TableName.Dates}) -
DatePart("ww", DateAdd("m", DateDiff("m", #1/1/1900#, {TableName.Dates}), #1/1/1900#)) + 1

or if you want it all spelled out...

"Week " &
ToText(DatePart("ww", {TableName.Dates}) -
DatePart("ww", DateAdd("m", DateDiff("m", #1/1/1900#, {TableName.Dates}), #1/1/1900#)) + 1, "0") &
" of " &
MonthName(DatePart("m", {TableName.Dates})) &
" " &
ToText(DatePart("yyyy", {TableName.Dates}), "0")

HTH,

Jason

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question