Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

382
Views
column "expired_date" is of type date but expression is of type text

I want update multiple row with multiple condition.

Here is my select query to test result.

select name, register_date, expired_date, to_char(register_date + interval '1 year' - interval '1 day', 'YYYY-MM-DD') from tb_agent where agent_id = agent_id and agent_id in (46,47,62)

It can show result like I expected,

But when I craft to multiple update with this code

update tb_agent set expired_date = (select to_char(register_date + interval '1 year' - interval '1 day', 'YYYY-MM-DD') from tb_agent where agent_id = agent_id) where agent_id in (46,47,62)

I got this

column "expired_date" is of type date but expression is of type text

register_date is date time column and expired_date is varchar

Is something wrong with my code?

Thanks, in advance.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

to_char converts the date to a formatted string. you can cast it instead as a date.

but the update statement could be simplified to the following as well:

update tb_agent 
set expired_date = (register_date + interval '1 year' - interval '1 day')::date
where agent_id in (46,47,62)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!