RE: Where condition doesn't work as expected - Mailing list pgsql-novice

From Ken Benson
Subject RE: Where condition doesn't work as expected
Date
Msg-id MWHPR19MB0096AB55D9A88E42CD8C8EC0A31F0@MWHPR19MB0096.namprd19.prod.outlook.com
Whole thread Raw
In response to Where condition doesn't work as expected  (William Colls <william@williamcollsassoc.ca>)
List pgsql-novice



Ken Benson | ken @ infowerks-dot-com

-----Original Message-----
From: William Colls <william@williamcollsassoc.ca> 
Sent: Saturday, February 8, 2020 2:40 PM
To: pgsql-novice@lists.postgresql.org
Subject: Where condition doesn't work as expected
>>>>-----Original Message-----
>>>>From: William Colls <william@williamcollsassoc.ca> 
>>>>Sent: Saturday, February 8, 2020 2:40 PM
>>>>To: pgsql-novice@lists.postgresql.org
>>>>Subject: Where condition doesn't work as expected
>>>>
>>>>I have the following condition a select statement:
>>>>
>>>>  WHERE "datetime" > '2019-03-31 23:59:59'
>>>>
>>>>datetime is a character field with data in the format YYYY-MM-DD HH:MM:SS. However it returns any line where the
datetimefield begins with 2019. I suspect that I should be using timestamp values, but I can't figure out how to cast
thedatetime field value to a timestamp.
 
>>>>

[Ken.B]  
SELECT to_date('20170103','YYYYMMDD');
https://www.postgresqltutorial.com/postgresql-to_date/


>>>>Thanks for your time.
>>>>
>>>>William.
>>>>
I have the following condition a select statement:

  WHERE "datetime" > '2019-03-31 23:59:59'

datetime is a character field with data in the format YYYY-MM-DD HH:MM:SS. However it returns any line where the
datetimefield begins with 2019. I suspect that I should be using timestamp values, but I can't figure out how to cast
thedatetime field value to a timestamp.
 

[Ken.B]  
SELECT to_date('20170103','YYYYMMDD');
https://www.postgresqltutorial.com/postgresql-to_date/

Thanks for your time.

William.




pgsql-novice by date:

Previous
From: William Colls
Date:
Subject: Where condition doesn't work as expected
Next
From: Bzzzz
Date:
Subject: Re: Where condition doesn't work as expected