Displaying Full Month Names

When reviewing last month’s services with a customer, I wanted to display the full month name on a slide. Obviously MMM would display “Dec” for December, but a complete month name? To save anyone else Googling, it’s MMMMM.

So the code below, asks “When did the last month start, when did the new month start, and therefore going back a day, when did the last month end ?” Then it writes out the month and year in the format I wanted “December 2024” for example.

[DateTime: =>ReportDate]
[DateTime: addMonths=-1, day=1, =>LastMonthStart]
[DateTime: day=1, =>LastMonthEnd]
[DateTime: value={LastMonthEnd}, AddDays=-1, =>MonthEnd]
[=: format(MonthEnd, 'yyyy'), =>Year]
[=: format(MonthEnd, 'MMMMM'), =>ReportMonth]
[: {ReportMonth} {Year}, =>ReportMonth]

And here’s an example slide using the code:

1 Like

Thanks @Emmelina - really useful post. :slightly_smiling_face:

One thing I have noticed above is that the Discourse Markdown formatting can sometimes try and helpfully interpret characters such as the ‘back-ticks’ around the NCalc code for the calls to the format() function - turning them into highlighting, rather than displaying the raw code.

I have posted on this previously: Community ToolTip: How to embed RMscript nicely in a post

Or more simply (?), escape the back-ticks with a back-slash:

[=: \`format(MonthEnd, 'yyyy')\`, =>Year]

appears as:

[=: `format(MonthEnd, ‘yyyy’)`, =>Year]

Thanks for supporting the Community - I look forward to reading more helpful nuggets as you find them…

Thanks. I can’t see a way to edit my original post, but thank you.