The MONTHS_BETWEEN function shows the returns the number of months between one date and another date. For example if we have a table called service_log and we store the date of a service in the column service_date we could do something like the query below;
SELECT MONTHS_BETWEEN(sysdate, service_date) as difference FROM service_log
This will show the months between the current date (sysdate) and the last service date as shown below;
DIFFERENCE ---------- 4.05244063620071684587813620071684587814 3 2.05244063620071684587813620071684587814 1.98792450716845878136200716845878136201 0.9556664426523297491039426523297491039427
When combining this with a round function you will be able to quickly build a report to show you if a equipment part is serviced on a monthly basis or not. An example using the round function is shown below;
SELECT ROUND(MONTHS_BETWEEN(sysdate, service_date),2) as difference FROM service_log
1 comment:
It was nice reading this blog. Thanks for sharing
Post a Comment