Обсуждение: above the date functionssssssss

Поиск
Список
Период
Сортировка

above the date functionssssssss

От
"Penchalaiah P."
Дата:
Hi good evening to every one………
 
i want to get month and year in the current date..
see this is date 2005-02-12... here date is 12 , month is 02 and year is 2005..
but i want format like 02-2005...

can u tell me how to do this

 

Thanks  &  Regards

Penchal reddy | Software Engineer           

Infinite Computer Solutions | Exciting Times…Infinite Possibilities...

SEI-CMMI level 5 | ISO 9001:2000

IT SERVICES | BPO                                                                                                                                                                          

Telecom | Finance | Healthcare | Manufacturing | Energy & Utilities | Retail & Distribution | Government                                                       

Tel +91-80-5193-0000(Ext:503)| Fax  +91-80-51930009 | Cell No  +91-9980012376|www.infics.com          

Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and/ or its Customers and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at info.in@infics.com and delete this mail from your records.

 

Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and / or its Customers and is intended for use only by the individual or the entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at info.in@infics.com and delete this email from your records.

Re: above the date functionssssssss

От
"A. Kretschmer"
Дата:
am  11.07.2006, um 17:04:06 +0530 mailte Penchalaiah P. folgendes:
> 
> Hi good evening to every one.........
> 
> i want to get month and year in the current date..
> see this is date 2005-02-12... here date is 12 , month is 02 and year is
> 2005..
> but i want format like 02-2005...

Simple, to_char is your friend:

test=*# select to_char(current_date, 'MM-YYYY');to_char
---------07-2006
(1 row)


HTH, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net===    Schollglas Unternehmensgruppe    === 


Re: above the date functionssssssss

От
Stuart
Дата:
Penchal reddy,

You should be able to use extract or date_trunc functions like in the documentation:

example:

SELECT EXTRACT(MONTH FROM DATE '2005-02-12') | "-" | EXTRACT(YEAR FROM DATE '2005-02-12');

or 

SELECT date_trunc('month', DATE '2005-02-12') | "-" | date_trunc('year', DATE '2005-02-12');



Stuart



-----Original Message-----
>From: "Penchalaiah P." <penchalaiahp@infics.com>
>Sent: Jul 11, 2006 7:34 AM
>To: pgsql-sql@postgresql.org
>Subject: [SQL] above the date functionssssssss
>
>
>Hi good evening to every one.........
>
>
>i want to get month and year in the current date..
>see this is date 2005-02-12... here date is 12 , month is 02 and year is
>2005..
>but i want format like 02-2005...
>
>can u tell me how to do this
>
>
>
>
>Thanks  &  Regards
>
>Penchal reddy | Software Engineer          
>
>
>Infinite Computer Solutions | Exciting Times...Infinite Possibilities...
>
>
>SEI-CMMI level 5 | ISO 9001:2000
>
>IT SERVICES | BPO
>
>
>Telecom | Finance | Healthcare | Manufacturing | Energy & Utilities |
>Retail & Distribution | Government
>
>
>Tel +91-80-5193-0000(Ext:503)| Fax  +91-80-51930009 | Cell No
>+91-9980012376|www.infics.com         
>
>
>Information transmitted by this e-mail is proprietary to Infinite
>Computer Solutions and/ or its Customers and is intended for use only by
>the individual or entity to which it is addressed, and may contain
>information that is privileged, confidential or exempt from disclosure
>under applicable law. If you are not the intended recipient or it
>appears that this mail has been forwarded to you without proper
>authority, you are notified that any use or dissemination of this
>information in any manner is strictly prohibited. In such cases, please
>notify us immediately at info.in@infics.com and delete this mail from
>your records.
>
>
>
>
>
>
>Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and / or its Customers and is
intendedfor use only by the individual or the entity to which it is addressed, and may contain information that is
privileged,confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it
appearsthat this mail has been forwarded to you without proper authority, you are notified that any use or
disseminationof this information in any manner is strictly prohibited. In such cases, please notify us immediately at
info.in@infics.comand delete this email from your records.
 



Re: above the date functionssssssss

От
Michael Fuhr
Дата:
On Tue, Jul 11, 2006 at 05:04:06PM +0530, Penchalaiah P. wrote:
> i want to get month and year in the current date..
> see this is date 2005-02-12... here date is 12 , month is 02 and year is
> 2005..
> but i want format like 02-2005...

See "Data Type Formatting Functions" and "Date/Time Functions and
Operators" in the "Functions and Operators" chapter of the
documentation:

http://www.postgresql.org/docs/8.1/interactive/functions-formatting.html
http://www.postgresql.org/docs/8.1/interactive/functions-datetime.html

-- 
Michael Fuhr