Re: [GENERAL] date with month and year

2015-05-22 Thread Karsten Hilbert
On Fri, May 22, 2015 at 09:46:10AM +0100, Tim Clarke wrote: On 22/05/15 09:40, Alban Hertroys wrote: On 21 May 2015 at 23:42, Karsten Hilbert karsten.hilb...@gmx.net wrote: You are right in the following aspect: - client sends in NOW at HERE - server knows HERE = UTC+2 And then the

Re: [GENERAL] date with month and year

2015-05-22 Thread Tim Clarke
On 22/05/15 09:40, Alban Hertroys wrote: On 21 May 2015 at 23:42, Karsten Hilbert karsten.hilb...@gmx.net wrote: You are right in the following aspect: - client sends in NOW at HERE - server knows HERE = UTC+2 And then the tectonic plate you're on shifts and you're suddenly in UTC+1 or +3

Re: [GENERAL] date with month and year

2015-05-22 Thread Alban Hertroys
On 21 May 2015 at 23:42, Karsten Hilbert karsten.hilb...@gmx.net wrote: You are right in the following aspect: - client sends in NOW at HERE - server knows HERE = UTC+2 And then the tectonic plate you're on shifts and you're suddenly in UTC+1 or +3 Thankfully, those things don't shift as

Re: [GENERAL] date with month and year

2015-05-22 Thread Gilles Darold
On 22/05/2015 06:09, Adrian Klaver wrote: On 05/21/2015 09:04 PM, Alvaro Herrera wrote: Adrian Klaver wrote: SELECT extract ( YEAR FROM school_day ) AS YEAR, Reformatting courtesy of pgFormatter(http://sqlformat.darold.net/). FWIW I think this indenting of

Re: [GENERAL] date with month and year

2015-05-21 Thread Daniel Torres
Sorry, forgot to told you what I'm trying, I have climate data and want to obtain mean temperature and total precipitation and that sort of things per month and year. Think date_trunc is a good solution, but any other advice would be very welcome. (I need to read more about time zones, I'm new at

Re: [GENERAL] date with month and year

2015-05-21 Thread Steve Crawford
On 05/21/2015 10:45 AM, Paul Jungwirth wrote: You really shouldn't use WITHOUT TIME ZONE. I'd like to know more about this. Can you say why? Start by reading about the date and time data types with special attention to section 8.5.3:

Re: [GENERAL] date with month and year

2015-05-21 Thread Thomas Kellerer
Brian Dunavant wrote on 21.05.2015 21:51: It's probably worth noting that both the Ruby 'best practice' AND Postgres have a failure case when dealing with future dates precisely because they are storing the data as UTC with a time zone. This is one case where storing the data WITHOUT TIME ZONE

Re: [GENERAL] date with month and year

2015-05-21 Thread Karsten Hilbert
Anyway, I agree that you have to store the time zone *somewhere*, and I suppose that's the reason Joshua remarked that you really shouldn't use WITHOUT TIME ZONE. And often a time has one perspective that is canonical or preferred, e.g. the time zone of the user who created the object.

Re: [GENERAL] date with month and year

2015-05-21 Thread Brian Dunavant
On Thu, May 21, 2015 at 5:27 PM, Thomas Kellerer spam_ea...@gmx.net wrote: Postgres does not store the time zone. When storing a timestamp with time zone, it is normalized to UTC based on the timezone of the client. When you retrieve it, it is adjusted to the time zone of the client. Sorry,

Re: [GENERAL] date with month and year

2015-05-21 Thread Karsten Hilbert
It's probably worth noting that both the Ruby 'best practice' AND Postgres have a failure case when dealing with future dates precisely because they are storing the data as UTC with a time zone. This is one case where storing the data WITHOUT TIME ZONE would actually save your bacon. From

Re: [GENERAL] date with month and year

2015-05-21 Thread Paul Jungwirth
what you've said above is incorrect. All WITH TIME ZONE does is tell PostgreSQL to apply timezone conversions during various operations. The stored data is represented as an epoch without any concept of the source data's timezone representation. Oh, very interesting! Thank you for pointing

Re: [GENERAL] date with month and year

2015-05-21 Thread Paul Jungwirth
Hi Steve, Thanks for such a thorough response! I agree that time is a lot trickier and trappier than one might expect, so it's good to learn how others grapple with it. Your original question had to do with month/year. Just to clarify, that was Daniel's original question, but you're

Re: [GENERAL] date with month and year

2015-05-21 Thread David G. Johnston
On Thu, May 21, 2015 at 2:10 PM, Paul Jungwirth p...@illuminatedcomputing.com wrote: Anyway, I agree that you have to store the time zone *somewhere*, and I suppose that's the reason Joshua remarked that you really shouldn't use WITHOUT TIME ZONE. And often a time has one perspective that is

Re: [GENERAL] date with month and year

2015-05-21 Thread Adrian Klaver
On 05/21/2015 11:56 AM, Steve Crawford wrote: On 05/21/2015 10:45 AM, Paul Jungwirth wrote: You really shouldn't use WITHOUT TIME ZONE. I'd like to know more about this. Can you say why? Start by reading about the date and time data types with special attention to section 8.5.3:

Re: [GENERAL] date with month and year

2015-05-21 Thread Adrian Klaver
On 05/21/2015 11:02 AM, Daniel Torres wrote: Sorry, forgot to told you what I'm trying, I have climate data and want to obtain mean temperature and total precipitation and that sort of things per month and year. Think date_trunc is a good solution, but any other advice would be very welcome.

Re: [GENERAL] date with month and year

2015-05-21 Thread Alvaro Herrera
Adrian Klaver wrote: SELECT extract ( YEAR FROM school_day ) AS YEAR, Reformatting courtesy of pgFormatter(http://sqlformat.darold.net/). FWIW I think this indenting of FROM inside an extract() call is odd and ugly --- probably just an accident resulting from

Re: [GENERAL] date with month and year

2015-05-21 Thread Adrian Klaver
On 05/21/2015 09:04 PM, Alvaro Herrera wrote: Adrian Klaver wrote: SELECT extract ( YEAR FROM school_day ) AS YEAR, Reformatting courtesy of pgFormatter(http://sqlformat.darold.net/). FWIW I think this indenting of FROM inside an extract() call is odd and ugly

Re: [GENERAL] date with month and year

2015-05-21 Thread Jan de Visser
On May 21, 2015 11:56:52 AM Steve Crawford wrote: The article does also display a couple attitudes that I feel are especially rampant in the web-development community. The first is that web developers shouldn't become educated about the capabilities of a database but rather use the database as

Re: [GENERAL] date with month and year

2015-05-21 Thread Paul Jungwirth
You really shouldn't use WITHOUT TIME ZONE. I'd like to know more about this. Can you say why? Are there any articles you'd recommend? I'm fond of normalizing all times to UTC and only presenting them in a time zone when I know the current perspective. I've written about that approach in a

Re: [GENERAL] date with month and year

2015-05-21 Thread Steve Crawford
On 05/21/2015 10:01 AM, Daniel Torres wrote: I everybody, I'm new in the Postgresql world, and have an easy question: Is it possible to have date type data that only contain month and year?, how can I obtain that from a timestamp (without time zone) column?... Others have offered good tips

Re: [GENERAL] date with month and year

2015-05-21 Thread Brian Dunavant
It's probably worth noting that both the Ruby 'best practice' AND Postgres have a failure case when dealing with future dates precisely because they are storing the data as UTC with a time zone. This is one case where storing the data WITHOUT TIME ZONE would actually save your bacon. From the

[GENERAL] date with month and year

2015-05-21 Thread Daniel Torres
I everybody, I'm new in the Postgresql world, and have an easy question: Is it possible to have date type data that only contain month and year?, how can I obtain that from a timestamp (without time zone) column? I've made this, but I think the result is a text, not a date select extract (Year

Re: [GENERAL] date with month and year

2015-05-21 Thread John McKown
On Thu, May 21, 2015 at 12:01 PM, Daniel Torres nobeea...@gmail.com wrote: I everybody, I'm new in the Postgresql world, and have an easy question: Is it possible to have date type data that only contain month and year?, how can I obtain that from a timestamp (without time zone) column? I've

Re: [GENERAL] date with month and year

2015-05-21 Thread David G. Johnston
On Thursday, May 21, 2015, Daniel Torres nobeea...@gmail.com wrote: I everybody, I'm new in the Postgresql world, and have an easy question: Is it possible to have date type data that only contain month and year?, how can I obtain that from a timestamp (without time zone) column? I've made

Re: [GENERAL] date with month and year

2015-05-21 Thread Paul Jungwirth
Is it possible to have date type data that only contain month and year?, how can I obtain that from a timestamp (without time zone) column? I think you want date_trunc, which will cut everything down to the first of the month, e.g 2015-01-01, 2015-02-01, etc. The results will still be dates,

Re: [GENERAL] date with month and year

2015-05-21 Thread Joshua D. Drake
On 05/21/2015 10:01 AM, Daniel Torres wrote: I everybody, I'm new in the Postgresql world, and have an easy question: Is it possible to have date type data that only contain month and year?, how can I obtain that from a timestamp (without time zone) column? I've made this, but I think the