1

I would like to change only the date part while retaining the time part untouched on postgresql datetime column?

2019-09-02 10:00:00

to

2019-10-26 10:00:00

4
  • 2
    add an interval. select '2019-09-02 10:00:00'::timestamp + '54 days'::interval; Commented Oct 26, 2019 at 6:44
  • please be more specific. Commented Oct 26, 2019 at 6:51
  • i want to update date of that entire column by not changing the time Commented Oct 26, 2019 at 6:53
  • 1
    That's what Jason's expression will do Commented Oct 26, 2019 at 7:19

1 Answer 1

1

You don't specify the logic you want to use. If you want to add or subtract an interval, you can use:

select '2019-09-02 10:00:00'::timestamp + interval '1 month 24 day'

If you want to directly specify the second date:

select '2019-10-26'::timestamp + ('2019-09-02 10:00:00'::timestamp)::time
Sign up to request clarification or add additional context in comments.

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.