6

I have a string "2016-10-25T00:14:30.000" in PostgreSQL.

I want to convert the timestamp to an integer, e.g: 1477354441

And I want to add custom minutes to that value, e.g. 1477354441+544(minutes) = 1477387081

How to achieve this in PostgreSQL?

2
  • 1
    1477354441 is not a "timestamp" it's an integer value Commented Oct 25, 2016 at 10:18
  • ok then convert to integer Commented Oct 25, 2016 at 10:21

2 Answers 2

12
SELECT EXTRACT(EPOCH FROM TIMESTAMP '2016-10-25T00:14:30.000');

SELECT EXTRACT(EPOCH FROM TIMESTAMP '2016-10-25T00:14:30.000' + INTERVAL '544 min');
Sign up to request clarification or add additional context in comments.

1 Comment

nice, it will help
0

Try this combination of two functions

SELECT 
extract(epoch from to_timestamp('2016-10-25T00:14:30.000','yyyy-MM-ddTHH24:mi:ss.ms'))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.