Skip to main content
Question

Add Year (if Not Current) to MM/DD


Forum|alt.badge.img+6
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!
This topic has been closed for replies.

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.

Forum|alt.badge.img+6

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)

Forum|alt.badge.img+6

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))


Yes, I had that backwards. Glad to hear it's working.