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
-
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. -
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 variableBirthDate. -
Get the current date
The flow retrieves today’s date (without time) and stores it inCurrentDate. -
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 inDaysAlive. -
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
Post a Comment