0

When I execute the following query, It updates the date field with time zone

update person set hiredate='2018-06-18 23:59:59-04:00' where id=5684

When I query the same as:

select * from person where id=5684

I get following value for hiredate: 2018-06-19 09:29:59 (in My timezone +5:30)

But I want to execute a query as

update person set hiredate=now()::date + time '23:59:59-04:00' where id=5684

and run the select query, I get the hiredate as: 2018-06-18 23:59:59

Please help me how I can

2
  • Is the time zone on the server the same as yours? Commented Jun 18, 2018 at 15:07
  • are you executing the query and checking the result in the same time zone ? Commented Jun 18, 2018 at 18:16

2 Answers 2

2

time is short for time without time zone. Try

UPDATE person
       SET hiredate = now()::date + time with time zone '23:59:59-04:00'
       WHERE id = 5684;
Sign up to request clarification or add additional context in comments.

Comments

-1

I think this is what you want is

update person set hiredate= timestamp with   
time zone now()::date + time '23:59:59-04:00' 
where id=5684;

1 Comment

time '23:59:59-04:00' is as same as using time '23:59:59' and that is not what the user probably wants.

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.