Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parse_ulid_timestamp() function #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rcoup
Copy link

@rcoup rcoup commented Jan 8, 2020

Extracts the timestamp from a generated ULID

eg:

postgres=# select now(), parse_ulid_timestamp(generate_ulid());
              now              |     parse_ulid_timestamp
-------------------------------+----------------------------
 2020-01-08 14:04:43.441019+00 | 2020-01-08 14:04:43.441+00
(1 row)

@leocassarani
Copy link
Member

Hi @rcoup, thanks for your contribution.

This is not a use case that we've ever come across and we were curious to hear what you were hoping to achieve with this function. The way we use ULIDs is as opaque identifiers and we've never expected to be able to retrieve the timestamp portion from an existing ULID.

Look forward to hearing from you.

@rcoup
Copy link
Author

rcoup commented Feb 3, 2020

Used it for tracing & debugging: grabbing chunks of records associated with a time range or figuring out when a record appeared, in situations where for whatever reason there aren't associated timestamp fields.

Most of the language ULID implementations (Python, Go, etc) seem to have parse methods.

@pksunkara
Copy link

@rcoup FWIW, pgx_ulid supports casting to timestamp. I needed this feature for generating creation timestamps from id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants