Year (start date) + Months (duration) = Year (end date) - Problem

Hi Guys,

I have extracted date in a form (dd.mm.yyyy) with Screen scraping - full text (while table was not redable with data scraping) and then with string manipulation got a desired form of date. I have also extracted loan duration which is given in a form of months (everything is a string variable). The end date should be as follows:
ED = dd.mm.yyyy + months = dd.mm.yyyy (new date should be in a same form as a start date).

Is there any “elegant” (short) solution how to solve this without using excel or e. scope?

Inside the Excel the solution is:
30.03.2017(date in cell A1) - start date
71 (number of months in cell A2) - duration in months
28.02.2023 (result in cell A3 using EDATE(A1;A2)) - end date
The above example should demonstrate what I want to achieve. I hope I was clear enough

I would very much appreciate the Help.

Thank you in advance,

@zlatko_gradascevic,

You can achieve this using assign activity as

End Date = Start date.AddMonths(A2)…

We have predefined class to add months or days or hours whatever… So if you have starting date and number of months to add, you can simply use the above.

Thanks for Tipp, but my Start Date and Months (with full text extracted) are String variables and AddMonths function is not String member, so I can not project End Date by simply applying this function.

What other steps do I need to perform first (changing variables, converting?)

Thanks!

Use this to convert string to DateTime format, so that you can use the above function to add months to the start date.

@zlatko_gradascevic

the above placed example is just to illustrate how this can easily be done inside Excell environment.

Can you explain what all you want to do?

I used Full text activity and from the desktop app from certain field I have extracted date (for. example 30.03.2017 - in this very form. Then after navigating trough desk. app again I applied Full text and extracted number of Months (71). Both extracted data (Date and number of months are saved as a string variables.
I just want to get the future date = start date + number of months (in the same form as start date - 28.02.2023)

I hope it is more clear now.
Regards,

Yes, you are clear enough …

Lets say, your string variables are startDateString and weekString…

Create new variable of type date as StartDate and assign the value as convert .ToDateTime(startDateString )

So it will give you the date format of your scraped data.

Then use… StartDate.AddMonths(CInt(weekString))

This will surely help you @zlatko_gradascevic

hi @zlatko_gradascevic

follow these steps:

  1. use split method with “.” like this:
    strArr (array of string) = str11.Split({"."},StringSplitOptions.None) —> by this you’ll get day, month and year separately.
  2. use this day, month, year in declaration of new DateTime
    d1 (Datetime) =
    New Datetime(Convert.ToInt32(strArr(2)),Convert.ToInt32(strArr(1)),Convert.ToInt32(strArr(0)))
  3. Assign NewDate1 = d1.AddMonths(71) —> instead of 71, pass your variable having month. (to add 71 months in d1 (date))
  4. print it in a form as you want it like —> Newdate1.ToString(“dd.MM.yyyy”)

Refer this xaml : date1.xaml (5.9 KB)

hope this ll help you :slight_smile:

2 Likes

Many thanks to both of you!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.