I want to write quarter start date and quarter end date based on the current date
Q1: 1 January, 2022 to 31 March, 2022
Q2: 1 April, 2022 to 30 June, 2022
Q3: 1 July, 2022 to 30 September, 2022
Q4: 1 October, 2022 to 31 December, 2022
so if the current date is 4 February, 2022, it should give me Q1 start and end date,
So how can i automate it and keeping the year as current year inorder to make it dynamic.
Following best practices, you can separate it into two different components.
1. Calculating the quarter:
Create a function (workflow) with arguments in_dtDate as DateTime and out_intQuarter
Assign out_Quarter to (in_dtDate.Month - 1) \ 3 + 1
2. Returning the start and end date
Create a function (workflow) which accepts in_intQuarter and out_strQuarterDates
Create a switch statement of 1-4, which sets assigns out_strQuarterDates to the strings you listed.
Invoke both workflows from the component you need it from. If you want to pass the current date into the first component, use DateTime.Now.
Let’s assume the input date is in String format stored in InputDateStr, then you would need to convert it to DateTime format first, else you could directly assign the Date value to InputDate.