How to Calculate difference of DOB from Current Date in no of days, month and year

Discussion in 'Free Source Codes' started by Rajat Agarwal, Jan 21, 2024.

    
  1. Rajat Agarwal

    Rajat Agarwal Member


    Dear Experts

    Can anyone calculate difference of dob from current date in format no of Days Month & Year
    Example
    DOB 3/1/2020
    Current Date. 21/1/2024
    No of Days. 1478 days
    No of Months. 48 Months
    No of Years 4 years
    Total. 4Y 0M 17D
    . . . . .
     
    Last edited: Jan 21, 2024


  2. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    Search for TIME DIFFERENCE Calculator in the Forum.

    I have uploaded the code there -- you can use the same or modify as per your needs.
     


  3. Rajat Agarwal

    Rajat Agarwal Member


    Sir, I had already made the tdl but there is some error in months and years....

    As I have use this coding
    End Date =CurrentDatedetails
    Start Date=DOBDate

    [System : Formula]
    DaysDiff : #CurrentDateDetail - #DOBDate
    MonthsDiff : @@DaysDiff / 30
    YearsDiff : @@MonthsDiff / 12
     

    Attached Files:



  4. Sai Vineeth

    Sai Vineeth Active Member



  5. Rajat Agarwal

    Rajat Agarwal Member


    Thank you Vineeth Ji...As per your suggestion I have used the above codes but the total is going different.
    I have shared a picture below and the code is

    [Part:TotalDaysMonthYear]
    Line:TotalDaysMonthYearTitle
    Border:Thick Box
    Space Left:10

    [Line:TotalDaysMonthYearTitle]
    Field:Medium Prompt, Name Field
    Local: Field: Medium Prompt:Set as: "(Total Days / Months / Years) :"
    Local: Field: Medium Prompt: Style: Normal Bold
    Local: Field: Medium Prompt: Align:Center
    Local: Field: Medium Prompt: Width:40
    Local: Field: Medium Prompt: Skip : Yes
    Space Top:1
    Local: Field: Name Field:Set as: $$String:mad:@DaysDiff + "Days / " + $$String:mad:@MonthsDiff + "Months / " + $$String:mad:@YearsDiff + "Years"
    Local: Field: Name Field: Style: Normal Bold
    Local: Field: Name Field: Type:Duration
    Local: Field: Name Field: Format:YMD
    Local: Field: Name Field: Align:Center
    Local: Field: Name Field: Width: 40
    Local: Field: Name Field: Set Always:Yes
     

    Attached Files:

    Last edited: Jan 22, 2024


  6. Sai Vineeth

    Sai Vineeth Active Member


    Use format : "Year,month,Day"
     


  7. Rajat Agarwal

    Rajat Agarwal Member


    After using that format 1.4.2022 to 1.4.2023

    In Total Column the result was incorrect as it shows 2 years 11 months and 29 days while in separates days months and years is correct...

    As shown in pictures
     


  8. Sai Vineeth

    Sai Vineeth Active Member


    I mean
    [Line:TotalDaysMonthYearTitle]
    ...

    Local: Field: Name Field:Set as: @@DaysDiff
    Local: Field: Name Field: Style: Normal Bold
    Local: Field: Name Field: Type:Duration
    Local: Field: Name Field: Format:"Year,month,Day"
     
    naren1234 likes this.


  9. Rajat Agarwal

    Rajat Agarwal Member


    Result is still 12 months and 5 days
     


  10. Sai Vineeth

    Sai Vineeth Active Member


    yeah that's correct.
    if it is beyond 12 months then Year will get added
    If 1.4.2022 - 31.5.2023
    then it will be
    1 Year, 1 Month and 29 Days
     


  11. Rajat Agarwal

    Rajat Agarwal Member


    1. So what is the correct code to get the result
     


  12. Sai Vineeth

    Sai Vineeth Active Member


    If you want to in some other format,
    then you need to write your function to
    compute days months and years from days and format according to your wish
     


  13. Rajat Agarwal

    Rajat Agarwal Member


    Okay but I don't know how to use function ....to get total no of days month and year
     


  14. Rajat Agarwal

    Rajat Agarwal Member


    Can anyone know how to calculate no of days month and year in single field...
     


  15. Rajat Agarwal

    Rajat Agarwal Member


    [Part:TotalDaysMonthYear]
    Line:TotalDaysMonthYearTitle
    Border:Thick Box
    Space Left:10

    [Line:TotalDaysMonthYearTitle]
    Field:Medium Prompt, Name Field
    Local: Field: Medium Prompt:Set as: "(Total Days / Months / Years) :"
    Local: Field: Medium Prompt: Style: Normal Bold
    Local: Field: Medium Prompt: Align: Center
    Local: Field: Medium Prompt: Width: 40
    Local: Field: Medium Prompt: Skip : Yes
    Space Top:1
    Local: Field: Name Field:Set as: @@DaysDiff; + "Days /" + $$String:mad:@MonthsDiff + "Months /" + $$String:mad:@YearsDiff + "Years"
    Local: Field: Name Field: Style: Normal Bold
    Local: Field: Name Field: Type:Duration
    Local: Field: Name Field: Format:"Day, Month, Year"
    Local: Field: Name Field: Align:Center
    Local: Field: Name Field: Width: 40
    Local: Field: Name Field: Set Always:Yes


    [System : Formula]
    DaysDiff : #CurrentDateDetail - #DOBDate
    MonthsDiff : @@DaysDiff / 30
    YearsDiff : @@MonthsDiff / 12
     


Share This Page