Skip to main content
Question

Display Month and Year from date field

  • July 26, 2016
  • 0 replies
  • 454 views

I have a generic date field.  I'd like it to display MONTH YYYY i.e. JULY 2016.

Tweaking the date field i am able to get close (JULY 1 2016) but the date still shows 1.  Is there a formula that can get me there?

This topic has been closed for replies.

Here is some code to use

var date DateWords = [My Date Field];
var text Month = Case(Month($DateWords),
1, "January",
2, "February",
3, "March",
4, "April",
5, "May",
6, "June",
7, "July",
8,"August",
9,"September",
10,"October",
11,"November",
12,"December");

$Month & "  " & ToText(Year($DateWords))

  • Author
  • Registered
  • July 26, 2016
That worked great, Mark! I had to adjust the type of field to be a Formula - Text.  I assumed it should be a date formula field but was wrong.  Thanks for helping again!!!

  • Author
  • Registered
  • August 2, 2016
I've got a curveball to add to the mix. Is it possible to adjust this formula to default to n/a when no date is listed in the [My date field]?

sujre, no problem

var date DateWords = [My Date Field];
var text Month = Case(Month($DateWords),
1, "January",
2, "February",
3, "March",
4, "April",
5, "May",
6, "June",
7, "July",
8,"August",
9,"September",
10,"October",
11,"November",
12,"December");

var MMMDDYYY = $Month & "  " & ToText(Year($DateWords));

if(IsNull([My Date Field]), "n/a", $MMMDDYYY)

  • Author
  • Registered
  • August 2, 2016
It doesn't like the last variable "A variable declaration must be followed by a type."

right,
change
var MMMDDYYY = $Month & "  " & ToText(Year($DateWords));

to

var text MMMDDYYY = $Month & "  " & ToText(Year($DateWords));

  • Author
  • Registered
  • August 2, 2016
I need one more if variable.  If the My Date Field occurred on or before 1977, default to "blank".  I've spent an hour tweaking the formula by myself but haven't gotten anywhere.

var date DateWords = [My Date Field];
var text Month = Case(Month($DateWords),
1, "January",
2, "February",
3, "March",
4, "April",
5, "May",
6, "June",
7, "July",
8,"August",
9,"September",
10,"October",
11,"November",
12,"December");

var MMMDDYYY = $Month & "  " & ToText(Year($DateWords));

if(
IsNull([My Date Field]), "n/a",
Year([My Date Field]) <= 1977, null,
$MMMDDYYY)