Baby123
(Baby)
January 31, 2024, 10:50am
1
Hi team,
If frequency is annual and month is May 2024 .
So I need 05/01/2023 to 31/12/2023.
If frequency is monthly and month is June 2024.
I need 05/01/2024 to 05/31/2024(Previous mnth).
If frequency is Quarlty and month will be 1,4,7,10
If month is 1 then I need previous 3 months like
10/01/2023 to 12/31/2023.
I need this montha and date values dynamically.
Can any one help me .
I need dynamic flow for the above query .
If frequency and month changes it will give correct values.
mkankatala
(Mahesh Kankatala)
January 31, 2024, 10:52am
2
Hi @Baby123
To get the first date,
str_firstdate = New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToString
To get the last date,
str_lastedate = New DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month)).ToString
Hope it helps!!
mkankatala
(Mahesh Kankatala)
January 31, 2024, 11:10am
4
Could you be more elaborate, getting some confusion what is Annually and Monthly.
I am clear about Quarter.
Give me the proper input and output… @Baby123
Hope you understand!!
Baby123
(Baby)
January 31, 2024, 11:17am
5
If frequency is annual and month is 1 (current month).
I need to fetch the date like
From date is 01/01/2023
To date is 31/12/2023.
Gap will be 1 year because frequency is annual.
If frequency monthly and month is 1 ( current month).
From date : 12/01/2023
Todate : 12/31/2023
mkankatala
(Mahesh Kankatala)
January 31, 2024, 12:37pm
6
Hi @Baby123
Please check the below workflow:
2024.xaml (24.6 KB)
Hope you understand!!
Baby123
(Baby)
January 31, 2024, 6:14pm
7
Hi @mkankatala ,
This is not crt flow .
Let me explain again
.
1). Frequency : Annual
Month : 1 (that means current month)
If frequency is annual and month is Jan2024 so, I want output like this.
Fromdate : 12/01/2023
Todate: 12/31/2023
Fromdate and todate gap will be 1 year that means annual.
2). If frequency :Monthly
Montha : 1 (current month).
Output: from date : 12/01/2023
Todate : 12/31/2023
Gap will be 1 month.
3). If frequency : Quetrly:
Month like this (1,4,7,10).
If month 1
Fromdate: 10/01/2023
Todate :12/31/2023
For example month 4 menas
From date: 01/01/2024
Todate: 03/31/2024.
Note: i want these dynamically.
Based on current month and frequency Bot will able to get fromdate and to date.
Please suggest and send me the flow of possible
mkankatala
(Mahesh Kankatala)
January 31, 2024, 6:19pm
8
The above code will satisfy the 2nd and 3rd condition, I have to change the lastDate variable expression to get the required output for the 1st condition.
I have a small doubt if the input is like below
Frequency is annual
Input is March 2024 then what is the output you want.
Hope you understand!!
Baby123
(Baby)
January 31, 2024, 6:24pm
9
Thank you I will check and let you know.
Annual output like this
Fromdate: 03/31/2023
Todate: 02/29/2024
mkankatala
(Mahesh Kankatala)
January 31, 2024, 6:37pm
10
In the first Else if block replace the Expression for the LastDate variable… @Baby123
- Assign -> LastDate = DateTime.ParseExact(Input, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture).AddYears(1).AddDays(-1).ToString("MM/dd/yyyy")
After replacing this, the whole process is completed and all conditions got satisfied.
Hope it helps!!
1 Like
mkankatala
(Mahesh Kankatala)
January 31, 2024, 6:43pm
11
Check the below image of the required output -
If you find the solution for you query, Make my post mark as solution to close the loop.
Happy Automation!!
Anil_G
(Anil Gorthi)
January 31, 2024, 7:51pm
12
@Baby123
You can use this
ToDate = New DateTime(Now.Year,Now.Month,1).Adddays(-1)
FromDate = ToDate.Adddays(1).AddMonths(If(Frequency="Annual",-12,If(Frequency="Quarterly",-3,-1)))
Hope this helps
Cheers
Baby123
(Baby)
February 1, 2024, 10:06am
13
Hi @mkankatala .
Sorry …
If frequency is Annual and months March 2024
From date is : 03/01/2023
Todate: 02/29/2024
Like this
Previous year March 1st 2023 to Feb last date current year(2024)
mkankatala
(Mahesh Kankatala)
February 1, 2024, 10:51am
14
Okay @Baby123
Then change the FirstDate and LastDate Variables expressions as below in the First Else If condition which is checking for annual.
- Assign -> FirstDate = DateTime.ParseExact(Input, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture).AddYears(-1).ToString("MM/dd/yyyy")
- Assign -> LastDate = DateTime.ParseExact(Input,"MMMM yyyy",System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString("MM/dd/yyyy")
Check the below output,
Hope it helps and Happy Automation!!
Baby123
(Baby)
February 1, 2024, 12:14pm
15
For monthly also I have new change
If month is Aug 2024 .
I need previous month 1st date and. Last date .
Output:
From date: 07/01/2024
Todate : 07/31/2024
If month is Aug 2025
Output will be :
07/01/2025
07/31/2025.
Make sure year also change based on the input
mkankatala
(Mahesh Kankatala)
February 1, 2024, 12:38pm
16
Okay @Baby123
Then change the FirstDate and LastDate Variables expressions as below in the First Else If condition which is checking for Monthly.
- Assign -> FirstDate = DateTime.ParseExact(Input, "MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture).AddMonths(-1).ToString("MM/dd/yyyy")
- Assign -> LastDate = DateTime.ParseExact(Input,"MMMM yyyy",System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString("MM/dd/yyyy")
Check the output -
If you got the solution for your query, make my post mark as solution to close the loop.
If you have any other modifications required, please close this loop and Post your query in the new post.
Hope you understand!!
Baby123
(Baby)
February 1, 2024, 1:31pm
17
Hi @mkankatala ,
Quetrly condition not working.
I am getting first date correctly but I am not getting last date properly.
Month : April 2024
I am getting first date : 01/01/2024
But last date will be 03/31/2024
But I am getting 02/28/2024.
first date : DateTime.ParseExact(Input, “MMMM yyyy”, CultureInfo.InvariantCulture).AddMonths(-3).ToString(“MM/dd/yyyy”)
Last date: DateTime.ParseExact(Input, “MMMM yyyy”, CultureInfo.InvariantCulture).AddMonths(-1).AddDays(-1).ToString(“MM/dd/yyyy”)
Please suggest
mkankatala
(Mahesh Kankatala)
February 1, 2024, 2:13pm
18
Okay @Baby123
Then change the LastDate Variables expressions as below in the Third Else If condition which is checking for Quarterly.
- Assign -> LastDate = DateTime.ParseExact(Input,"MMMM yyyy",System.Globalization.CultureInfo.InvariantCulture).AddDays(-1).ToString("MM/dd/yyyy")
Check the below output -
Note : There is small change in the code at one assign activity,
Now it is like below,
- Assign -> QuarterMonths = {01,04,10}
Change as below,
- Assign -> QuarterMonths = {01,04,07,10}
Hope it helps!!
1 Like
pikorpa
(Piotr Kołakowski)
February 1, 2024, 4:24pm
19
Hey @Baby123
please try this workflow:
BlankProcess87.zip (2.8 KB)
Sagar1
(Sagar Das)
February 1, 2024, 4:49pm
20
Hello @Baby123 ,
Hope you are doing well!
please have a look on the attached code if this helps ultimately.
DynamicDateExtract.xaml (32.0 KB)