Skip to content
Advertisement

Set minutes of timestamp to a specific value

What is the easiest way to set the exact minutes value of a timestamp?

This only adds minutes instead of setting the exact value:

Advertisement

Answer

Use date_trunc() before you add 2 minutes:

Or, to retain seconds and sub-seconds:

Demo:

Should be substantially faster than manipulating the text representation and casting back.

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