Re: [GENERAL] to_timestamp alternatives

2016-01-05 Thread Jim Nasby
On 1/1/16 4:11 AM, Thomas Kellerer wrote: You only need to provide the text value to be casted (no format mask). Use only a single expression without those unnecessary parentheses: SELECT gmt_date||' '||lpad(gmt_time,8,'0')::timestamp You don't need the lpad() either: SELECT gmt_date

Re: [GENERAL] to_timestamp alternatives

2016-01-04 Thread Jim Nasby
On 1/1/16 7:15 AM, Alban Hertroys wrote: Since you're dealing with GPS data and presumably have lat/long, it shouldn't be hard to do this dynamically either, either by just blindly dividing longitude by 15 or using actual timezone shape polygons and @> or <@. That would be a bad idea for globa

Re: [GENERAL] to_timestamp alternatives

2016-01-01 Thread Alban Hertroys
> On 01 Jan 2016, at 0:46, Jim Nasby wrote: > > BTW, my recommendation would be to store in a timestamptz field *with the > correct timezone*, and then convert on output as necessary. This is easy to > do by either > > SET timezone > > or > > SELECT timestamptz_field AT TIME ZONE '…'; This

Re: [GENERAL] to_timestamp alternatives

2016-01-01 Thread Thomas Kellerer
gkhan schrieb am 31.12.2015 um 22:34: Thanks very much for both of your replies. I had tried something similar and gotten an error, so I am probably making a stupid mistake. If I try this, it works: SELECT ('09.03.2014'||' '||lpad('3:00:00',8,'0'),'DD.MM. HH24:MI:SS')::timestamp but i

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread Adrian Klaver
On 12/31/2015 03:05 PM, gkhan wrote: Follow-up: My initial question was about oddly-formatted date/times. The suggested solution of casting directly to timestamp with ::timestamp is not as flexible as the to_timestamp function that I was trying to avoid. For example, this fails because of the

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread Jim Nasby
On 12/31/15 5:05 PM, gkhan wrote: For example, this fails because of the day-before-month format: Right, which is why Tom had in his example: regression=# set datestyle = dmy; BTW, my recommendation would be to store in a timestamptz field *with the correct timezone*, and then convert on out

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread gkhan
Follow-up: My initial question was about oddly-formatted date/times. The suggested solution of casting directly to timestamp with ::timestamp is not as flexible as the to_timestamp function that I was trying to avoid. For example, this fails because of the day-before-month format: SELECT ('18.0

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread Adrian Klaver
On 12/31/2015 01:34 PM, gkhan wrote: Thanks very much for both of your replies. I had tried something similar and gotten an error, so I am probably making a stupid mistake. If I try this, it works: SELECT ('09.03.2014'||' '||lpad('3:00:00',8,'0'),'DD.MM. HH24:MI:SS')::timestamp but if

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread gkhan
Oh sorry, what a dumb mistake! ::timestamp works, of course! Thanks -- View this message in context: http://postgresql.nabble.com/to-timestamp-alternatives-tp5879723p5879746.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread David G. Johnston
On Thu, Dec 31, 2015 at 2:34 PM, gkhan wrote: > Thanks very much for both of your replies. I had tried something similar > and > gotten an error, so I am probably making a stupid mistake. If I try this, > it works: > >SELECT ('09.03.2014'||' '||lpad('3:00:00',8,'0'),'DD.MM. > HH24:MI:SS

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread gkhan
...I meant to add, "and we therefore try to store all time and date values in 'timestamp without time zone' variables. -- View this message in context: http://postgresql.nabble.com/to-timestamp-alternatives-tp5879723p5879739.html Sent from the PostgreSQL - general mailing list archive at Nabble

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread gkhan
Thanks very much for both of your replies. I had tried something similar and gotten an error, so I am probably making a stupid mistake. If I try this, it works: SELECT ('09.03.2014'||' '||lpad('3:00:00',8,'0'),'DD.MM. HH24:MI:SS')::timestamp but if I use column names instead of the text,

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread Tom Lane
gkhan writes: > Hi. I have a practical need to convert some badly-formatted date/times into > 'timestamp without time zone' data types. Like other scientists, I try to > avoid timezone problems by sticking to UTC and using the 'timestamp without > time zone' data type whenever possible. > In t

Re: [GENERAL] to_timestamp alternatives

2015-12-31 Thread Adrian Klaver
On 12/31/2015 12:30 PM, gkhan wrote: Hi. I have a practical need to convert some badly-formatted date/times into 'timestamp without time zone' data types. Like other scientists, I try to avoid timezone problems by sticking to UTC and using the 'timestamp without time zone' data type whenever pos