How to split date

I need to fetch a date from UI
example- 06/11/2019 5:00 PM - this is the format
I to split so that I must get only 2019 as output

Hi @KarthikBallary,

Declare a variable of type datetime, and assign the value you have. Then use variable.year


but the date will be web browser. it will fetched from the browser

I think it will be in the form of string

6/11/2019 5:00 PM GMT-8 this is the format

Please use this code in assign activity:




Try this:

Datetime.parseexact(“06/11/2019 5:00 PM”,“MM/dd/yyyy h:mm tt”,system.globalization.cultureinfo.invariantculture).tostring(“yyyy”)

If it is in the first format you provided, then the above method will work, or

If it is as 6/11/2019 5:00 PM GMT-8, then use

strDate.Substring(5,4) or


1 Like
  1. 2019
  2. 2018
  3. 2020

bullets 1,2,3 are the icons in UI. suppose my date matches with 2019 it must click on 1 if 2020 it must click on 3.

how to implement this

Check the bullet selector. If its having year value, then pass year variable inside the selector.


Use Switch case for each year.

but this is hard coded. suppose if it is 12/06/2010 ?

Yeah, I just tried to trim the year from the string whatever you have provided @KarthikBallary,

You can use this for whatever may be the format. First it will trim with “/” then it will trim the year

how to convert 12/06/2019 to 20190612?

This working fine. can you explain the syantax. wht .last() means?

suppose I need this in format 20191106…we can concat

After splitting the string with “/” , then we are taking out the required second string from the splitted one… I mean , if we are splitting 26/07, when we give it as split("/“c).First(), we will get 26 and if if we give it as split(”/"c).Last() , we will get 07 …