Design, Database

Random Numbers And Zettel UID Timestamps In Notion

Screen Shot 2020-05-20 at 11.47.07 AM.png

๐ŸŒณ More UID Methods

The timestamp function in Notion is a form of a date function that, instead of showing date and time, will show a timestamp in milliseconds, corresponding to time elapsed since January 1, 1970. For example, May 19 2020's timestamp is 1589860800000. Here are a few uses for Notion's timestamp in regards to creating a unique identifier.

Create A Timestamp UID

If you're a fan of Zettelkasten and a Notion user, you're going to want to play around with timestamps. Here are some common ways Zettel users utilize timestamps, only Notion-fied. (More about the philosophy behind timestamp IDs.)

timestamp(prop("Created"))
  • Upside to timestamp ID: Creates a unique number ID

  • The downside to timestamp ID: Does not calculate seconds. Users must wait one minute between the creation of each page. Else, two entries will have the same ID.

Screen Shot 2020-05-20 at 12.09.04 PM.png

Use Timestamp To Generate A Random Number

Yes, it is possible to generate a random number in Notion. You still have to wait a minute between each entry for this one, but at least there's a formula that can return a better-looking number. This random generator isn't perfect but it looks like the best option so far. By the way, I didn't make this. props to this guy.

mod(mod(timestamp(prop("Created Time")) * 100011979 + 500067713, 900066731) * mod(timestamp(now()) * 800067089 + 800068411, 800053967) + 900067309, 900066571)

Screen Shot 2020-05-20 at 12.10.51 PM.png

Timestamp With Other Properties

Long-Form UID Without Tags

If you want a timestamp ID that includes the name of the note or the name of its tag inside the database, use the concat function like so:

concat(format(mod(mod(timestamp(prop("Created Time")) * 100011979 + 500067713, 900066731) * mod(timestamp(now()) * 800067089 + 800068411, 800053967) + 900067309, 900066571)) + prop("Name"))

Alternatively, Eliminate spaces in UID:

concat(format(mod(mod(timestamp(prop("Created Time")) * 100011979 + 500067713, 900066731) * mod(timestamp(now()) * 800067089 + 800068411, 800053967) + 900067309, 900066571)) + replaceAll(slice(prop("Name"), 0, 10), " ", ""))

Screen Shot 2020-05-20 at 12.11.44 PM.png

Long Form UID With Tags And Name

Here, we're going to add another element โ€” a tag, and place it at the end of the UID in brackets.

concat(format(mod(mod(timestamp(prop("Created Time")) * 100011979 + 500067713, 900066731) * mod(timestamp(now()) * 800067089 + 800068411, 800053967) + 900067309, 900066571)) + replaceAll(slice(prop("Name"), 0, 10), " ", "") + "[" + prop("Tag") + "]")

Screen Shot 2020-05-20 at 12.12.35 PM.png

What I Use In My Notes

Below is an example of the same UID with the addition of new symbols based on a tag selection. For instance, in my notes, I categorize everything into:

  • _overview (the parent note)(O^/)

    • child_internal (exclusively mental notes)(<"">)

    • child_external (notes from external sources)([""])

Also, my personal UID eliminates all spaces in the note's title and include only the first 10 characters, in addition to implementation of the above symbols.

if(prop("Tags") == "Internal", concat("<" + format(mod(mod(timestamp(prop("Created Time")) * 100011979 + 500067713, 900066731) * mod(timestamp(now()) * 800067089 + 800068411, 800053967) + 900067309, 900066571)) + replaceAll(slice(prop("Name"), 0, 10), " ", "") + ">"), if(prop("Tags") == "Overview", concat("O^/" + format(mod(mod(timestamp(prop("Created Time")) * 100011979 + 500067713, 900066731) * mod(timestamp(now()) * 800067089 + 800068411, 800053967) + 900067309, 900066571)) + replaceAll(slice(prop("Name"), 0, 10), " ", "")), if(prop("Tags") == "External", concat("[" + format(mod(mod(timestamp(prop("Created Time")) * 100011979 + 500067713, 900066731) * mod(timestamp(now()) * 800067089 + 800068411, 800053967) + 900067309, 900066571)) + replaceAll(slice(prop("Name"), 0, 10), " ", "") + "]"), "")))
  • *Note: this method will help with the timestamp limitations above. Although the original timestamp may be identical to another, the addition of the name of the note in some variation will aid the randomness.

Screen Shot 2020-05-20 at 12.14.51 PM.png