Hello! Everyone,
I have 9 dates format dd/mm/yyy. I need to find the middle date of the each month in 9 dates.
Ex - Actual date: (12/04/2022) here I need to get the date (15/04/2022)
Date and month are dynamic. If month is having 31 days need to get the date of 15 or 16. If it is 30 days need to get 15.
Is it possible to get the date like this?
Regards,
Yoichi
(Yoichi)
April 26, 2022, 6:30am
3
Hi,
Can you try the following?
dtVar=DateTime.ParseExact("12/04/2022","dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture)
Then
New DateTime(dtVar.Year,dtVar.Month,DateTime.DaysInMonth(dtVar.Year,dtVar.Month)>>1).ToString("dd/MM/yyyy")
or
New DateTime(dtVar.Year,dtVar.Month,CInt(Math.Round(DateTime.DaysInMonth(dtVar.Year,dtVar.Month)/2))).ToString("dd/MM/yyyy")
Regards,
Hi! @Yoichi
Thanks for the quick reply. I encountered this error.
Regards,
Yoichi
(Yoichi)
April 26, 2022, 6:53am
5
Hi,
Is item variable datetime string such as β12/04/2021β?
If so, can you create DateTime variable (letβs say dtVar) and use the following expression in Assign activity?
dtVar=DateTime.ParseExact(item,"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture)
Then use this expression
New DateTime(dtVar.Year,dtVar.Month,DateTime.DaysInMonth(dtVar.Year,dtVar.Month)>>1).ToString("dd/MM/yyyy")
Regards,
Hi!
Yes, in item I have 9 different dates and months with the same format( dd/MM/yyyy).
As you mentioned i have taken one for each which is the type argument of datetime. and also i have created date time variable.
it is throwing an error
Error: Specified cast is not valid
Regards,
Yoichi
(Yoichi)
April 26, 2022, 7:12am
7
Hi,
Can you check your variable type? And also the following sample might help you.
Main.xaml (8.1 KB)
Regards,
1 Like
SamanGuruge
(Palliya Guruge Saman Priyalal)
April 26, 2022, 8:22am
9
@Unknown_User ,
you can use following example also if you want
DateTime.Parse(now.year.ToString +β/β+now.Month.ToString +β/β+ (DateTime.DaysInMonth(now.Year,now.Month)/2).ToString)
1 Like
Hi @Yoichi and @SamanGuruge
I need to get the first date of next month.
since, we have got the middle of the month date right. need to get the next month 1 st date.
EX:- Date(15/04/2021) expected date (01/05/2021)
Do i need to create new thread or can i continue here?
Regards,
Yoichi
(Yoichi)
April 26, 2022, 8:45am
12
Hi,
Can you try the following expression?
dtVar=DateTime.ParseExact(item,"dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture)
Then
New DateTime(dtVar.Year,dtVar.Month,1).AddMonths(1).ToString("dd/MM/yyyy")
Regards,
1 Like
ppr
(Peter Preuss)
April 26, 2022, 8:45am
13
please create a new topic. Thanks
1 Like
SamanGuruge
(Palliya Guruge Saman Priyalal)
April 26, 2022, 8:54am
14
Hi @Unknown_User
DateTime.Parse(now.Year.ToString +β/β+(now.Month+1).ToString+β/1β)
1 Like
ppr
(Peter Preuss)
April 26, 2022, 9:05am
15
@Unknown_User , @SamanGuruge
we focus to scope the different topics to only one case. So researchers can easier find the solutions when they are researching for their case
lets assume:
would produce:
an invalid date
we could handle like
2 Likes
system
(system)
Closed
April 29, 2022, 9:06am
16
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.