# Discussions

View Only

## Add Year (if Not Current) to MM/DD

• #### 1.  Add Year (if Not Current) to MM/DD

Posted 05-23-2017 15:55
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!

• #### 2.  RE: Add Year (if Not Current) to MM/DD

Top
Contributor
Posted 05-23-2017 16:55
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)

• #### 3.  RE: Add Year (if Not Current) to MM/DD

Top
Contributor
Posted 05-23-2017 16:56
Oh and to sort just sort on your date field even though it may not be used as a column on the report.

• #### 4.  RE: Add Year (if Not Current) to MM/DD

Posted 05-23-2017 17:27

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.

• #### 5.  RE: Add Year (if Not Current) to MM/DD

Top
Contributor
Posted 05-23-2017 17:37
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)

• #### 6.  RE: Add Year (if Not Current) to MM/DD

Posted 05-23-2017 21:12

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

• #### 7.  RE: Add Year (if Not Current) to MM/DD

Top
Contributor
Posted 05-23-2017 21:16