Re: [GENERAL] difference between current_timestamp and now() in quotes
current_timestamp is the reserved keyword of postgreSQL. When you executes it within single quotation mark it treated as string that is the only reason it thrown error. Now() is an in-built function you can use it with/without single quotation mark. For more information refere the below link. http://www.postgresql.org/docs/8.1/static/sql-keywords-appendix.html -- Thanks Regards Dhaval Jaiswal EnterpriseDB www.enterprisedb.com From: Grzegorz Jaśkiewicz gryz...@gmail.com To: GENERAL pgsql-general@postgresql.org Sent: Thursday, January 22, 2009 7:22:21 PM Subject: [GENERAL] difference between current_timestamp and now() in quotes test2=# create table dupa(a timestamp, b serial); NOTICE: CREATE TABLE will create implicit sequence dupa_b_seq for serial column dupa.b CREATE TABLE test2=# insert into dupa(a) select current_timestamp from generate_series(1,100); INSERT 0 100 test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported LINE 1: insert into dupa(a) select 'current_timestamp' from generate ^ test2=# insert into dupa(a) select 'now()' from generate_series(1,100); INSERT 0 100 Any ideas why the difference ? -- GJ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] difference between current_timestamp and now() in quotes
On 2009-01-22, Adrian Klaver akla...@comcast.net wrote: On Thursday 22 January 2009 8:16:46 am Alvaro Herrera wrote: Grzegorz Jaśkiewicz escribió: test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported LINE 1: insert into dupa(a) select 'current_timestamp' from generate... ^ test2=# insert into dupa(a) select 'now()' from generate_series(1,100); INSERT 0 100 Any ideas why the difference ? The parser handles CURRENT_TIMESTAMP (and others) specially, and doesn't recognize it in quotes. I don't know why 'now()' works; I think it is a literal of type unknown. I guess it's expanded to the actual value in later parsing stages. -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support At least on 8.2 'now()' does not work either at least not in the way I think you want. I get: test=# SELECT 'now()'; ?column? -- now() (1 row) 'now' is a string which can be translated to timestamp now() is a function that returns the current timestamp current_timestamp is a constant that does the same -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] difference between current_timestamp and now() in quotes
test2=# create table dupa(a timestamp, b serial); NOTICE: CREATE TABLE will create implicit sequence dupa_b_seq for serial column dupa.b CREATE TABLE test2=# insert into dupa(a) select current_timestamp from generate_series(1,100); INSERT 0 100 test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported LINE 1: insert into dupa(a) select 'current_timestamp' from generate... ^ test2=# insert into dupa(a) select 'now()' from generate_series(1,100); INSERT 0 100 Any ideas why the difference ? -- GJ -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] difference between current_timestamp and now() in quotes
On 22/01/2009 13:52, Grzegorz Jaśkiewicz wrote: test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported This doesn't answer your question, but you use current_timestamp without the quotes, thus - insert into dupa(a) select current_timestamp ... Ray. -- Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland r...@iol.ie Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals -- -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] difference between current_timestamp and now() in quotes
Grzegorz Jaśkiewicz escribió: test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported LINE 1: insert into dupa(a) select 'current_timestamp' from generate... ^ test2=# insert into dupa(a) select 'now()' from generate_series(1,100); INSERT 0 100 Any ideas why the difference ? The parser handles CURRENT_TIMESTAMP (and others) specially, and doesn't recognize it in quotes. I don't know why 'now()' works; I think it is a literal of type unknown. I guess it's expanded to the actual value in later parsing stages. -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] difference between current_timestamp and now() in quotes
On Thursday 22 January 2009 8:16:46 am Alvaro Herrera wrote: Grzegorz Jaśkiewicz escribió: test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported LINE 1: insert into dupa(a) select 'current_timestamp' from generate... ^ test2=# insert into dupa(a) select 'now()' from generate_series(1,100); INSERT 0 100 Any ideas why the difference ? The parser handles CURRENT_TIMESTAMP (and others) specially, and doesn't recognize it in quotes. I don't know why 'now()' works; I think it is a literal of type unknown. I guess it's expanded to the actual value in later parsing stages. -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support At least on 8.2 'now()' does not work either at least not in the way I think you want. I get: test=# SELECT 'now()'; ?column? -- now() (1 row) -- Adrian Klaver akla...@comcast.net -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] difference between current_timestamp and now() in quotes
Adrian Klaver wrote: On Thursday 22 January 2009 8:16:46 am Alvaro Herrera wrote: Grzegorz Jaśkiewicz escribió: test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported LINE 1: insert into dupa(a) select 'current_timestamp' from generate... ^ test2=# insert into dupa(a) select 'now()' from generate_series(1,100); INSERT 0 100 Any ideas why the difference ? The parser handles CURRENT_TIMESTAMP (and others) specially, and doesn't recognize it in quotes. I don't know why 'now()' works; I think it is a literal of type unknown. I guess it's expanded to the actual value in later parsing stages. -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support At least on 8.2 'now()' does not work either at least not in the way I think you want. I get: test=# SELECT 'now()'; ?column? -- now() (1 row) Try select now();
Re: [GENERAL] difference between current_timestamp and now() in quotes
On Thursday 22 January 2009 9:07:37 am Jason Long wrote: Adrian Klaver wrote: On Thursday 22 January 2009 8:16:46 am Alvaro Herrera wrote: Grzegorz Jaśkiewicz escribió: test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported LINE 1: insert into dupa(a) select 'current_timestamp' from generate... ^ test2=# insert into dupa(a) select 'now()' from generate_series(1,100); INSERT 0 100 Any ideas why the difference ? The parser handles CURRENT_TIMESTAMP (and others) specially, and doesn't recognize it in quotes. I don't know why 'now()' works; I think it is a literal of type unknown. I guess it's expanded to the actual value in later parsing stages. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support At least on 8.2 'now()' does not work either at least not in the way I think you want. I get: test=# SELECT 'now()'; ?column? -- now() (1 row) Try select now(); Yes that is how I use it :) My example referred to the original message that said select 'now()' worked but 'current_timestamp' did not. -- Adrian Klaver akla...@comcast.net -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] difference between current_timestamp and now() in quotes
well, I am asking that - for pure curiosity reason. I got a function in C, that automagically puts all data in quotes, and that's how I came across that strange difference between current_time and now(). Funny enough, pg will translate first one to latter in domains, for instance. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Resp.: [GENERAL] difference between current_timestamp and now() in quotes
2009/1/22, Adrian Klaver akla...@comcast.net: On Thursday 22 January 2009 8:16:46 am Alvaro Herrera wrote: Grzegorz Jaśkiewicz escribió: test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported LINE 1: insert into dupa(a) select 'current_timestamp' from generate... ^ test2=# insert into dupa(a) select 'now()' from generate_series(1,100); INSERT 0 100 Any ideas why the difference ? The parser handles CURRENT_TIMESTAMP (and others) specially, and doesn't recognize it in quotes. I don't know why 'now()' works; I think it is a literal of type unknown. I guess it's expanded to the actual value in later parsing stages. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support At least on 8.2 'now()' does not work either at least not in the way I think you want. I get: test=# SELECT 'now()'; ?column? -- now() (1 row) Table 8-13. Special Date/Time Inputs http://www.postgresql.org/docs/current/interactive/datatype-datetime.html bdteste=# SELECT 'now'::date, 'yesterday'::date, 'today'::date, 'tomorrow'::date; date|date|date|date +++ 2009-01-22 | 2009-01-21 | 2009-01-22 | 2009-01-23 (1 registro) Osvaldo -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: Resp.: [GENERAL] difference between current_timestamp and now() in quotes
On Thursday 22 January 2009 18:57:16 Osvaldo Kussama wrote: 2009/1/22, Adrian Klaver akla...@comcast.net: On Thursday 22 January 2009 8:16:46 am Alvaro Herrera wrote: Grzegorz Jaśkiewicz escribió: test2=# insert into dupa(a) select 'current_timestamp' from generate_series(1,100); ERROR: date/time value current is no longer supported LINE 1: insert into dupa(a) select 'current_timestamp' from generate... ^ test2=# insert into dupa(a) select 'now()' from generate_series(1,100); INSERT 0 100 Any ideas why the difference ? The parser handles CURRENT_TIMESTAMP (and others) specially, and doesn't recognize it in quotes. I don't know why 'now()' works; I think it is a literal of type unknown. I guess it's expanded to the actual value in later parsing stages. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support At least on 8.2 'now()' does not work either at least not in the way I think you want. I get: test=# SELECT 'now()'; ?column? -- now() (1 row) Table 8-13. Special Date/Time Inputs http://www.postgresql.org/docs/current/interactive/datatype-datetime.html bdteste=# SELECT 'now'::date, 'yesterday'::date, 'today'::date, 'tomorrow'::date; date|date|date|date +++ 2009-01-22 | 2009-01-21 | 2009-01-22 | 2009-01-23 (1 registro) Osvaldo 'now' != 'now()' And also the cast matters, IMHO. -- Fahrbahn ist ein graues Band weisse Streifen, grüner Rand -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] difference between current_timestamp and now() in quotes
Adrian Klaver escribió: At least on 8.2 'now()' does not work either at least not in the way I think you want. I get: test=# SELECT 'now()'; ?column? -- now() (1 row) alvherre=# select 'now()'::unknown::timestamptz; timestamptz --- 2009-01-22 15:01:46.352979-03 (1 fila) It even works if you use text instead of unknown. -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] difference between current_timestamp and now() in quotes
On Thursday 22 January 2009 10:04:05 am Alvaro Herrera wrote: Adrian Klaver escribió: At least on 8.2 'now()' does not work either at least not in the way I think you want. I get: test=# SELECT 'now()'; ?column? -- now() (1 row) alvherre=# select 'now()'::unknown::timestamptz; timestamptz --- 2009-01-22 15:01:46.352979-03 (1 fila) It even works if you use text instead of unknown. I see my problem I was just doing a select. When I did an insert into a timestamp field than the 'now()' form worked. Learn something new everyday :) -- Adrian Klaver akla...@comcast.net -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general