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 using postgresql)

Thank you,
Daniel

2015-05-21 12:45 GMT-05:00 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 Rails context here:
>
> http://illuminatedcomputing.com/posts/2014/04/timezones/
>
> I find that this helps me to ignore time zones in most parts of my
> application and cut down on my timezone-related bugs.
>
> Thanks!
>
> Paul
>
>
>
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>


[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 from '2001-05-01 20:21:00'::TIMESTAMP WITHOUT TIME
ZONE)||'-'|| extract(Month from '2001-05-01 20:21:00'::TIMESTAMP WITHOUT
TIME ZONE);



Any help is welcome, thanks

Daniel


[GENERAL] change data type from text to numeric

2014-11-26 Thread Daniel Torres
Hi everyone,

sorry to bother you with a simple question, (I'm a new user of postgresql),
how do I change the data type of a column of text, to numeric or integer?

I tried with:

ALTER TABLE table_name
 ALTER COLUMN col_name TYPE integer
;

It gives me a mistake
ERROR:  la columna  no puede convertirse automáticamente al tipo integer
SUGERENCIA:  Especifique una expresión USING para llevar a cabo la
conversión.

translation: the column can't be converted automatically to type integer
 specify an expression using USING to make the conversion.

I also tried on pgadmin3, but couldn't found how to do it...

thanks,
Daniel