Pavunkumar
Pavunkumar

Reputation: 5335

Postgresql : Getting specific field from Data Value

Is there any way to get the get the specific values from date such as year , month , day . Actually we have in php date function . If we give date (Y-m ) ; it will give us 2010-07 . I want like this in postgres(psql) .

Thanks in Advance...

Upvotes: 0

Views: 182

Answers (1)

MD Sayem Ahmed
MD Sayem Ahmed

Reputation: 29166

SELECT to_char(CURRENT_DATE, 'MM') FROM v_use_doc_line ;

This will provide you with the month value of the CURRENT_DATE. If you need year, just replace MM with YYYY.

I hope you can guess now what you should do to get the day :).

For further information, see the to_char function of postgresql.

Upvotes: 2

Related Questions