w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Turn days into weeks, months, years.ORACLE

To get the number of months you could use months_between

SELECT select AVG(months_between(SYSDATE,DOB)) AS
AVERAGE_AGE_IN_MONTHS

For years, just do months_between/12

SELECT select AVG(months_between(SYSDATE,DOB)/12) AS
AVERAGE_AGE_IN_YEARS

For weeks, i would just take your result for days and divide it by 7.

You might have to handle the results to fit your needs, but i think this should cover it.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.