Reputation: 127
I need to select values from a Database where I have a complete Date. Now I have to get this Date without the Day because I have to group and count them per Month.
I did it like this, but this will get me the Month like for January with 1 and I need 01...
(extract(YEAR,Month from ak.date ) || '.' ||extract(Month from ak.date) ) as Datum
Upvotes: 5
Views: 11447
Reputation: 60262
Another way:
TRUNC(ak.date, 'MM')
Advantage of this is that date sorting and date arithmetic still work.
Upvotes: 1
Reputation: 26333
Use the TO_CHAR
function for this:
TO_CHAR(ak.date, 'YYYY.MM') as Datum
Upvotes: 8