Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract year and month from timestamp(6)

I have database, where i have inserted timestamps(6) in this format : 18-AUG-14 02.49.27.000000000 PM .

I want to extract it into this: 2014-08

Its called ISO 8601

like image 556
Martin Kóňa Avatar asked Oct 21 '25 23:10

Martin Kóňa


1 Answers

You'll need to use the to_char function to extract the year-month from timestamp.

select to_char(timestamp, 'yyyy-mm') from your_table
like image 174
Sathyajith Bhat Avatar answered Oct 23 '25 15:10

Sathyajith Bhat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!