Oracle SQL: selecting a date field without a day (month and year only)

I need to select values ​​from a database where I have the full date. Now I have to get this date without a day, because I have to group and count them per month.

I did it this way, but it will give me a month, like in January, from 1, and I need 01 ...

(extract(YEAR,Month from ak.date ) || '.' ||extract(Month from ak.date) ) as Datum 
+4
source share
2 answers

Use the TO_CHAR function to do this:

 TO_CHAR(ak.date, 'YYYY.MM') as Datum 
+7
source

Another way:

 TRUNC(ak.date, 'MM') 

The advantage of this is that sorting by date and arithmetic by date continue to work.

0
source

Source: https://habr.com/ru/post/1485633/


All Articles