Home > Software design >  Compare date and time columns in postgresql
Compare date and time columns in postgresql

Time:07-17

I have a table that contains 2 columns date and time, both are character Varying, I am trying to return those only which are greater than the current date and time

Date time
17-07-2022 05:00
17-07-2022 06:00
17-07-2022 10:00
17-07-2022 17:00
17-07-2022 18:00
18-07-2022 17:00

Expected Output

If current time is : 12:00 AM

Date time
17-07-2022 17:00
17-07-2022 18:00
18-07-2022 17:00

CodePudding user response:

You can try below mentioned query:

select * from tab where concat(date_, ' ', time_)::timestamp <current_timestamp;

Demo

  • Related