Need to calculate the days for different year and month

12/1/2021-2/28/2022

In above days whole December,January and February is covered

So my output should be 31 for december
31 for January
28 for February and how to implement in code

Hi @sruthesanju ,

Could you let us know How would you want to represent this Output ? Do you want these in the form of Date type variables or String type ?

It should be in string. Output should be 31,31,28

Hello @sruthesanju
Refer to this Xaml file, you will get some idea.
MonthEndDate.xaml (7.7 KB)
image
image

1 Like

Unable to open the xaml can you please share the pic

@sruthesanju
Try this.
Forum_MonthEndDate.zip (139.3 KB)


DateStr="12/1/2021-2/28/2022"

StartDate=DateTime.ParseExact(DateStr.Split("-")(0).ToString,"M/d/yyyy",System.Globalization.CultureInfo.InvariantCulture)

TargetDate=DateTime.ParseExact(DateStr.Split("-")(1).ToString,"M/d/yyyy",System.Globalization.CultureInfo.InvariantCulture)

While Loop Condition= StartDate< TargetDate

StartDate=StartDate.addmonths(1)

Print->   DateSerial(StartDate.Year,StartDate.Month,0).ToString("dd-MM-yyyy")

Getting error as Implement conversation from string to char for first start date assign

@sruthesanju ,
here, the startdate and Target date should be the Datetime variable.
DateStr is String Variable

It date time variable only

Can you show the whole error @sruthesanju ?

@sruthesanju ,

I believe the Error is due to a missing suffix literal c in the Split delimiter. Modify the above Expressions by adding a c after the delimiter and Check if it works :

.....DateStr.Split("-"c)(0).....