Skip to content
Advertisement

How to check TIMESTAMP format in SQL?

What’s the best way to check if the VARIANT TYPE with JSONs with value similar to TIMESTAMP_NTZ has correct format?

For example, this is the correct format that I would like to have

but there are times when it looks different in database, like this

I would like to detect records which are in a different format than the reference.

I tried with simple LIKE, but it omits formats that could be different than this.

Advertisement

Answer

You may use a regular expression to check the equality of the desired format. I will extend this answer if the rdbms is known.

MySQL & SQLite:

Oracle:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement