Convert a date to decimal

0

I have this cast in my Oracle SP, but at the time of grouping it, it tells me that it can not be done for the same topic, but if I can run it out with a simple select, does anyone know if there is any alternate way to do this?

    SELECT case when START_TIME > 24*60*60*30 then cast(cast(EXTRACT(YEAR from E.ON_DATE) AS VARCHAR(4)) || substr('00' || CAST(EXTRACT(month from E.ON_DATE) AS VARCHAR(2)),-2,2) || substr('00' || CAST(EXTRACT(day from E.ON_DATE) AS VARCHAR(2)),-2,2) as NUMBER(9))  + 1 
else 
cast(cast(EXTRACT(YEAR from E.ON_DATE) AS VARCHAR(4)) || substr('00' || CAST(EXTRACT(month from E.ON_DATE) AS VARCHAR(2)),-2,2) || substr('00' || CAST(EXTRACT(day from E.ON_DATE) AS VARCHAR(2)),-2,2) as NUMBER(9)) END TIEMPO_NUEVO
FROM EVENT E
    
asked by Cris Valdez 21.10.2016 в 16:11
source

1 answer

1

Well at one time you may notice one of the problems. You forgot the case when in front of START_TIME > 24*60*60*30 then ... , both in SELECT as in GROUP BY . Maybe you have other problems, but you will have to share the exact error to be able to help you better.

Regarding what the title of your question is:

  

Convert a date to a decimal

... I propose a simpler way to do it:

(EXTRACT(YEAR from E.ON_DATE) * 10000)
+ (EXTRACT(month from E.ON_DATE) * 100)
+ EXTRACT(day from E.ON_DATE)
    
answered by 21.10.2016 в 16:45