Is there a way to obtain the first day of the year and last day of the month from the Get Current date and time tool?
Here's a sample of a GETDATES subflow I keep in almost all my flows and adjust as needed:
Hello @lipster26
You can use actions "Convert datetime to text", "Convert text to datetime" and "Add to datetime" for this kind of purpose.
Please refer my sample flow in screenshot and code snippet below:
DISABLE Text.ToDateTime Text: $'''2021-05-31''' DateTime=> CurrentDate
DateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateOnly CurrentDateTime=> CurrentDate
# The first day of the year
Text.FromCustomDateTime DateTime: CurrentDate CustomFormat: $'''yyyy-01-01''' Result=> FirstDayOfTheYearText
Text.ToDateTime Text: FirstDayOfTheYearText DateTime=> FirstDayOfTheYear
# The last day of the month
DateTime.Add DateTime: CurrentDate TimeToAdd: 1 TimeUnit: DateTime.TimeUnit.Months ResultedDate=> NextMonthOfToday
Text.FromCustomDateTime DateTime: NextMonthOfToday CustomFormat: $'''yyyy-MM-01''' Result=> FirstDayOfNextMonthText
Text.ToDateTime Text: FirstDayOfNextMonthText DateTime=> FirstDayOfNextMonth
DateTime.Add DateTime: FirstDayOfNextMonth TimeToAdd: -1 TimeUnit: DateTime.TimeUnit.Days ResultedDate=> LastDayOfThisMonth
# Display result
Display.ShowMessage Message: $'''%FirstDayOfTheYear%
%LastDayOfThisMonth%''' Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
Thank you.