OpenOffice で日数/月数/年数を計算する

OpenOffice で日数/月数/年数を計算する

OpenOffice で日数、月数、年数で年齢を調べる必要があります。

Microsoft Excel にありますDATEDIF()。これを使用して、2 つの日付間の日数/月数/年数の差を計算できます。

Age Calculation 
    You can calculate a persons age based on their birthday and todays date.
    The calculation uses the DATEDIF() function.        
    The DATEDIF() is not documented in Excel 5, 7 or 97, but it is in 2000. 
    (Makes you wonder what else Microsoft forgot to tell us!)   
    Birth date :    01-Jan-60       
    Years lived :   52   =DATEDIF(C8,TODAY(),"y")   
    and the months :    4    =DATEDIF(C8,TODAY(),"ym")
    and the days :  30   =DATEDIF(C8,TODAY(),"md")

以下の式で計算できますが、月を計算するのは面倒です。

Another way to calculate age         
This method gives you an age which may potentially have decimal places representing the months.
If the age is 20.5, the .5 represents 6 months.             
Birth date :    01-Jan-60
Age is :    52.41    =(TODAY()-C23)/365.25

答え1

ただYEARS()そしてMONTHS()関数の集合から日付/時刻関数:

=YEARS(01-Jan-60,NOW,1)

そして

=MONTHS(01-Jan-60,NOW,1)

経過した年数と月数の合計が得られます。年数の合計から残りの月数を得るには、剰余を使用します(Calcの場合:MOD()):

=MOD(MONTHS(01-Jan-60,NOW,1), 12)

合計月数を 12 で割った残りの 4 か月を返します。

もちろん、上記の数式に含まれる日付をセル参照に置き換えることもできます。=YEARS(A1,A2,1)セル A1 と A2 には日付が含まれていると想定しています。

関連情報