Calculate Your Age in Days - Power Automate Desktop Flow

Calculate Your Age in Days - Power Automate Desktop Flow

This flow asks the user to select their birth date and then calculates how many days they have lived so far. Finally, it shows the result in a motivational message.

Step-by-Step Explanation

  1. Show flow description
    The flow begins by displaying a message box explaining what the automation does: it will ask for your birth date and compute your age in total number of days.
  2. Prompt user to select their birth date
    A date selection dialog appears where the user picks their birthday. The selected date is saved in the variable BirthDate.
  3. Get the current date
    The flow retrieves today’s date (without time) and stores it in CurrentDate.
  4. Calculate the difference in days
    Using the DateTime.Subtract action, the flow subtracts the birth date from today's date. The result—total days alive—is stored in DaysAlive.
  5. Show the age in days with a motivational message
    A final message displays the number of days the user has lived so far, along with an encouraging note reminding them to make every day count.


Full Power Automate Desktop Code

Display.ShowMessageDialog.ShowMessage Title: $'''Description''' Message: $'''This flow prompts you to enter your birth date. Then, it calculates and displays your age in days.''' Icon: Display.Icon.Information Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True

# Prompt user to enter birth date
Display.SelectDateDialog.SelectDate Title: $'''Please select your birthday...''' Message: $'''Select your birth date...''' DateDialogFormat: Display.DateDialogFormat.DateOnly SelectedDate=> BirthDate ButtonPressed=> ButtonPressed

# Get today’s date and calculate difference
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateOnly CurrentDateTime=> CurrentDate
DateTime.Subtract FromDate: CurrentDate SubstractDate: BirthDate TimeUnit: DateTime.DifferenceTimeUnit.Days TimeDifference=> DaysAlive

# Display result
Display.ShowMessageDialog.ShowMessage Title: $'''Attention!''' Message: $'''Today is day #%DaysAlive%

Each day is unique. Make the most of it and don't forget to laugh!!!''' Icon: Display.Icon.Warning Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True
  

Comments

Popular posts from this blog

Part 1: Creating Code Apps in Power Apps - A step-by-step guide (with real errors I faced & how I fixed them)

Calling Microsoft Graph API from Power Automate Using Azure App Services – Step-by-Step Guide

Step-by-Step Guide: Power Automate Custom Connector Using Graph API from Azure App Service