Re: date with month and year

From: John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>
To: Daniel Torres <nobeeakon(at)gmail(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: date with month and year
Date: 2015-05-21 17:11:43
Message-ID: CAAJSdjjYKvz1c=82aHeHSuumUEGppTybiRkhAnzCbV8mZc3g=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, May 21, 2015 at 12:01 PM, Daniel Torres <nobeeakon(at)gmail(dot)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 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
>
>
​I don't think so. Mainly because a date, at least in PostgreSQL, is by
definition a month, day, and year. You could just arbitrarily set the day
to "01" because every month starts with day 1, I guess.​ Perhaps if you
said what you want to do with this type of date field? Of course, if you
really wanted to, you could create your own data type and conversions. But
that still wouldn't be a "date", exactly.

--
My sister opened a computer store in Hawaii. She sells C shells down by the
seashore.

If someone tell you that nothing is impossible:
Ask him to dribble a football.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2015-05-21 17:13:15 Re: date with month and year
Previous Message Daniel Torres 2015-05-21 17:01:09 date with month and year