Reformat date and time with now()

When I use now() I get the date and time in this format:
2/14/2023 11:05:35 AM
To save space, is there a way to reformat the output to:
2/14/23 11:05 AM
Many thanks!

You can change it within the date & time options either in a table or page formula!

1 Like

Thank you!
I feel stupid asking this…but how did you get to that screen?
I know how to get to date and time options for a field…but in this application the field is a combination of now()+text.

This is a page formula, so in a page I typed = and put the formula in, Now(), then pushed the date/time icon in the top right of the popup, and selected the format you mentioned.

1 Like

Thank you for your help…I see how to do that now.
That doesn’t seem to help in this case though, because the field is a text formatted formula:
Format(now())+": "+LineBreak()+thisRow.Notes

Ah, in the case of merging multiple pieces of text together, you can use .FormatDateTime().

1 Like

Hi @Gregg_Stebben :blush: !

Now() takes a precision optional input such as "second", "minute", "hour" and "day" (the default being "second").

So, using:

  • Now() or Now("second") will output something like:

    • 3/3/2023 10:11:12 AM ( M/D/YYYY hh:mm:ss A ) and will refresh every seconds
  • Now("minute") will output something like:

    • 3/3/2023 10:11 AM ( M/D/YYYY hh:mm A ) and will refresh every minutes
  • Now("hour") will output something like:

    • 3/3/2023 10:00 AM ( M/D/YYYY hh:00 A ) and will refresh every hours
  • Now("day") is the equivalent to Today() and will output something like:

    • 3/3/2023 ( M/D/YYYY ) and will refresh every days

And I have a small suggestion to make here, regarding this :

Why not use a formula such as:

  "{1}: {2}{3}",

In this Format() formula the placeholders in the template ("{1}: {2}{3}") will be replaced, once the formula runs, by :

  • {1} → Now("minute")
  • {2} → LineBreak()
  • {3} → thisRow.Notes

Which should give you the same result you probably already have using

Format(now())+": "+LineBreak()+thisRow.Notes

It’s just that it’s not recommended tu use + to concatenate things within Coda.
+ is, more often than not in these cases interpreted as the addition operator and can lead to weird looking/erroneous results down the line :innocent:

1 Like

Thank you so much!
I have seen the use of “{1}{2}{3}” but until now I didn’t understand how it worked…thank you!
And thank you for explaining how the timing with “precision” vs other modifiers works!
Is there a way to get the year to output with two digits (23) vs 4 digits (2023)?

Dear @Gregg_Stebben ,

Kind reminder where it was explained to you how to get the last two digit’s of the year


1 Like

No problem @Gregg_Stebben :blush: !

Yes, but you would need to deconstruct/reconstruct the date according to the format you want :innocent:

  "{1}/{2}/{3} {4}: {5}{6}",

In which :

  • {1} is the placeholder for → Today().Month()
  • {2} is the placeholder for → Today().Day()
  • {3} is the placeholder for → Today().Year().Right(2)
    (Which, in this case, extracts 2 characters from Today().Year() starting from the Right())
  • {4} is the placeholder for → Now("minute").ToTime()
    (As the date has been formatted previously with Today(), only the current time is needed now)
  • {5} is the placeholder for → LineBreak()
  • {6} is the placeholder for → thisRow.Notes

This should give you the desired result :blush:

Now, to avoid the Today() redundancy, you can store its value and give it a name using WithName() :blush:

And the previous formula becomes :

    "{1}/{2}/{3} {4}: {5}{6}",

Where T is the name of Today()'s value from which we later get the month, day and formatted year :blush: .

I used Today() instead of Now("minute") because only the date needed to be manipulated.
(I didn’t see the point of using Now("minute") multiple times just to get the date from it when there’s Today())

1 Like

Amazing, thank you!!!

No problem @Gregg_Stebben :grin: !

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.