on 11-30-2018 8:19 AM
Hi Guys,
I need to create a calculated column for finding difference between two dates in terms of Month.
Could anyone help!!!
select MONTHS_BETWEEN('20181001', '20181203') from dummy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
What do you mean by in terms of months?
What if the dates are 1/1/2019 to 2/15/2019, what would be the result? Is it 1 or 2 months?
What if the dates are 1/31/2019 to 2/15/2019, what would be the result? Is it 1 or 2 months?
Then we can suggest how to solve your problem.
Do you base the "month" with 30 days or is it based on the number of months in your dates?
Regards,
Loed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sagarika,
Please try this:
SELECT DATEDIFF(MONTH, '2019-01-01', '2020-01-01') AS "Months Difference";
Thank you,
Aziz
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sagarika, let us know in which sceneario it is not calculating as expected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.