Reputation: 151
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
Upvotes: 4
Views: 50627
Reputation: 1623
I've done this in this way -
select extract(year from timestmp) || '-' || extract(month from timestmp) from texmp1;
Hope this helps.
Here is the table structure:
create table texmp1
(
timestmp timestamp
);
Upvotes: 0
Reputation: 21851
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
Upvotes: 9