Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
sugurutaguchi
Partner - Contributor II
Partner - Contributor II

生年月日から現在までの経過月数を計算する方法

質問です。

とある生年月日のリストから、その人ごとに現在までの月数を出す計算をしたいと思っているのですが

何か、良い方法はないでしょうか?

たとえば、

1992/2/15 の誕生日の人がいて、この人の現在までの月数を出すため

現在の日付を誕生日で引いて経過日数を出すことは出来るのですが、そこから月数を出すための

計算方法が思いつきません。

初歩的な問題で申し訳ないのですが、みなさんのお力お借り出来ないでしょうか?

よろしくお願いいたします。

Labels (3)
1 Solution

Accepted Solutions
el_aprendiz111
Specialist
Specialist

Hi Suguru

SET MonthDiff = Num(((year($2) * 12) + month($2)) - (((year($1) * 12) + month($1))) + If(Day($1) > Day($2), 0, 1) );
LET vDateToday = NUM(Today()); 

EXAMPLE:
LOAD date(DATE,'DD/MM/YYYY') AS DATE,
$(MonthDiff(DATE,$(vDateToday))) AS MONTHSSSSS

;
LOAD * Inline
[
DATE,MonthsDifference
17/11/2014,
04/11/2015,
04/11/2013,
04/11/2011,
21/11/1975,
]
;

View solution in original post

2 Replies
el_aprendiz111
Specialist
Specialist

Hi Suguru

SET MonthDiff = Num(((year($2) * 12) + month($2)) - (((year($1) * 12) + month($1))) + If(Day($1) > Day($2), 0, 1) );
LET vDateToday = NUM(Today()); 

EXAMPLE:
LOAD date(DATE,'DD/MM/YYYY') AS DATE,
$(MonthDiff(DATE,$(vDateToday))) AS MONTHSSSSS

;
LOAD * Inline
[
DATE,MonthsDifference
17/11/2014,
04/11/2015,
04/11/2013,
04/11/2011,
21/11/1975,
]
;

sugurutaguchi
Partner - Contributor II
Partner - Contributor II
Author

Hi fer fer  SAN
This advice was very helpful !
thank you so very much