Add Year (if Not Current) to MM/DD

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
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!
Photo of Amber

Amber

  • 506 Points 500 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
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)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
Oh and to sort just sort on your date field even though it may not be used as a column on the report.
Photo of Amber

Amber

  • 506 Points 500 badge 2x thumb

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.

Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
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)
Photo of Amber

Amber

  • 506 Points 500 badge 2x thumb

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

Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
Yes, I had that backwards. Glad to hear it's working.