I try to select all records of a table (Postgres DB) with the following sql:
SELECT * FROM 'tablename' WHERE 'myTimestampRow' >= now()
There's allways an error message, telling me that there's an 'invalid input syntax for type timestamp with time zone: "myTimestampRow"'.
What's wrong with the above query?
Explanation: The above example shows the time and timestamp of all three functions working is the same. The current timestamp is basically used as the default timestamp value of a column in PostgreSQL. The current timestamp and the current time are to deliver the values with the time zone in PostgreSQL.
PostgreSQL compare date is used to compare date between two different dates, which we have used as an input. We can compare the date by using where and between clauses; we can also compare the date using the date_trunc function in PostgreSQL.
To calculate the difference between the timestamps in PostgreSQL, simply subtract the start timestamp from the end timestamp. Here, it would be arrival - departure . The difference will be of the type interval , which means you'll see it in days, hours, minutes, and seconds.
You can use the PostgreSQL Now() function to display the current date and time of the timezone (default or user-defined) without any timestamp. You can use the “timestamp” keyword along with the Now() function.
Lose the single-quotes:
SELECT * FROM tablename WHERE myTimestampRow >= now()
You can optionally double-quote column- and table-names, but no single-quotes; they will be interpreted as characters/strings.
You have
SELECT * FORM
instead of
SELECT * FROM
but that might be a typo in the question. I think your problem is the quoting of the columns, it should read either
SELECT * FROM table WHERE timestampRow >= now();
(no quotes) or
SELECT * FROM "table" WHERE "timestampRow" >= now();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With