0

I want to add the value of another colum (which is an an integer representing miliseconds) to a date value in an update query. I tried what this answer suggests but I can't find a way to not hardcode the value in the query but instead read it from the other column.

The two relevant fields are:

ScheduledExecuteDate: DATE(6)
RecurringInterval: INTEGER representing the number of miliseconds to add to the date

My query looks something like this:

UPDATE "Tasks" SET 
"ScheduledExecuteDate"="ScheduledExecuteDate" + interval ("RecurringInterval" / 1000) second 
WHERE "id" = 62

I've also tried 'second'. In both cases it throws an syntax error "at or near second" Also note that I have to wrap the column names in quotes since they are case sensitive.

I also tried

"scheduledExecuteDate"=DATE_ADD("scheduledExecuteDate", interval ("Tasks"."recurringInterval" / 1000) seconds)

like answered here

0

1 Answer 1

1

You can use make_interval() passing fractional seconds:

UPDATE "Tasks" 
  SET "ScheduledExecuteDate" = "ScheduledExecuteDate" 
                               + make_interval(secs => "RecurringInterval"::double precision / 1000) second 
WHERE "id" = 62
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.