Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle SQL: selecting date field without day (Only Month and Year)

Tags:

sql

oracle

plsql

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
like image 289
Fabian Avatar asked Feb 17 '23 06:02

Fabian


1 Answers

Use the TO_CHAR function for this:

TO_CHAR(ak.date, 'YYYY.MM') as Datum
like image 180
Ed Gibbs Avatar answered May 10 '23 14:05

Ed Gibbs