Forum Discussion

AmberPollard's avatar
AmberPollard
Qrew Assistant Captain
8 years ago

Add Year (if Not Current) to MM/DD

How would I change the formula to display the year IF it is not the current year?

var text MM = Right(ToText(Month([Date])),2);

var text DD = Left(ToText(Day([Date])),2);

If(IsNull([Date]), "",

$MM &"/"& $DD)

Also, if records are sorted highest to lowest by the (new) field, will higher (more recent) dates appear ABOVE the dates for the previous years?

I could sort by the [Date] field, but I concatenate the field above with another with some text details.

Thanks!
  • No Problem

    var text MM = Right(ToText(Month([Date])),2);

    var text DD = Left(ToText(Day([Date])),2);

    var text YYYY = IF(Year([Date]) = Year(Today()), ToText(Year([Date]));

    If(IsNull([Date]), "",

    List("/", $MM,  $DD, $YYYY)
  • Oh and to sort just sort on your date field even though it may not be used as a column on the report.
  • AmberPollard's avatar
    AmberPollard
    Qrew Assistant Captain

    I'm sorry, I pasted exactly and got an error about mismatched parenthesis. From what I could tell, another ")" should be added at the very end, but I'm still getting the same error.

  • It was acryaully the one above whech was missing the )

    var text MM = Right(ToText(Month([Date])),2);

    var text DD = Left(ToText(Day([Date])),2);

    var text YYYY = IF(Year([Date]) = Year(Today()), ToText(Year([Date])));

    If(IsNull([Date]), "",

    List("/", $MM, $DD, $YYYY)
  • AmberPollard's avatar
    AmberPollard
    Qrew Assistant Captain

    For the record, I think you had = instead of <>. I corrected the formula and changed for two year characters below. Thank you!!!


    var text MM = Right(ToText (Month([Date])),2);

    var text DD = Left(ToText(Day([Date])),2);

    var text YY = If(Year([Date]) <> Year(Today()), Right(ToText(Year([Date])),2));

    If(IsNull([Date]), "",

    List("/", $MM, $DD, $YY))