Skip to content

Instantly share code, notes, and snippets.

@ExcelExciting
Last active June 15, 2023 09:29
Show Gist options
  • Save ExcelExciting/575ffb1b7065424f85ed3899f0416bc6 to your computer and use it in GitHub Desktop.
Save ExcelExciting/575ffb1b7065424f85ed3899f0416bc6 to your computer and use it in GitHub Desktop.
Lambda - 00001 - Hijri Age Calculator Excel
HIJRIAGE =
/*Hijri Age Calculator allows you to calculate the age of person as per arabic calander.
https://excelexciting.com/how-to-calculate-hijri-age-in-excel/
EXAMPLE:
=HIJRIAGE("3/3/1991")
RESULT>> 31 years 10 months 25 days
If you like to cacluate the Gregorian Age then you need enter next argument as "g"
EXAMPLE:
=HIJRIAGE("3/3/1991","g")
RESULT>> 30 years 11 months 11 days
author,"Faraz Shaikh, Microsoft® MVP",
wesite,"www.ExcelExciting.com",
Created,"20211203",
Modified,"20220214"*/
LAMBDA(DOB,[CAL_TYPE],
LET(
v_hijri_month,12,
v_gregorian_today_date,TODAY(),
v_synodic_month,29.530575,
v_hijri_number_of_days_in_a_year,v_hijri_month*v_synodic_month,
v_gregorian_age_in_days,DATEDIF(DOB,v_gregorian_today_date,"D"),
v_gregorian_age_in_years,DATEDIF(DOB,v_gregorian_today_date,"Y"),
v_gregorian_age_in_month,DATEDIF(DOB,v_gregorian_today_date,"YM"),
v_gregorian_age_in_day,DATEDIF(DOB,v_gregorian_today_date,"MD"),
v_hijri_age_years,v_gregorian_age_in_days/v_hijri_number_of_days_in_a_year,
v_hijri_age_months,(v_hijri_age_years-INT(v_hijri_age_years))*v_hijri_month,
v_hijri_age_days,(v_hijri_age_months-INT(v_hijri_age_months))*v_synodic_month,
v_concat_hijri_age,CONCAT(
TEXT(INT(v_hijri_age_years),"00")," years ",
TEXT(INT(v_hijri_age_months),"00")," months ",
TEXT(INT(v_hijri_age_days),"00")," days"
),
v_concat_gregorian_age,CONCAT(
TEXT(INT(v_gregorian_age_in_years),"00")," years ",
TEXT(INT(v_gregorian_age_in_month),"00")," months ",
TEXT(INT(v_gregorian_age_in_day),"00")," days"
),
result,IF(ISOMITTED(CAL_TYPE),v_concat_hijri_age,IF(CAL_TYPE="g",v_concat_gregorian_age,v_concat_hijri_age)),
result
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment