Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi
there is 2 dates from date and to date .. and i want to get month difference from these two dates
like if
from date to date month difference
01-02-2019 02-02-2020 13
i tried this but this shows wrong results
month(from date) - month(to date)
and i also try this
month([from date] - [to date])
See if this works for you:
year(from date) * 12 + month(from date) - year(to date) * 12 - month(to date)
The logic is simple here - you're creating the date 2019-02-01 to months as well as 2020-02-02.
2019-02-01 becomes 24230
2020-02-02 becomes 24242
The difference between them is 24242-24230=12 months.
I guess this is what you expect to get, isn't it?
When i tried your expression .. i have one of the record like this
from date to date difference
and this is showing difference like -84,007 .. how is that possible ?
Check your date as it goes to 9018 years.
ohh
how i remove " - " minus sign ?
but i have some records like these
From date | to date | Difference |
7/23/2019 | 12/31/2019 | 0 |
7/28/2019 | 12/31/2019 | 0 |
7/28/2019 | 12/31/2019 | 0 |
8/4/2019 | 12/31/2019 | 0 |
8/4/2019 | 12/31/2019 | 0 |
8/8/2019 | 12/31/2019 | 0 |
5/8/2019 | 12/31/2019 | 0 |
1/1/2019 | 12/31/2019 | 0 |
2/18/2019 | 12/31/2019 | 0 |
5/14/2019 | 12/31/2019 | 0 |
7/28/2019 | 12/31/2019 | 0 |
3/15/2019 | 12/31/2019 | 0 |
6/9/2019 | 12/31/2019 | 0 |
1/16/2020 | 3/2/2020 | 0 |
1/8/2020 | 8/8/2020 | 0 |
and these show differences 0 which is incorrect..
A little script to show you how I might tackle this.
This takes into account days, so
2018-03-01 - 2018-01-20 would return 1 (complete month)
i did not understand .. i need simple expression