Split data

Hello,

How can i split this data

7100 / 29 to 7100 and 29 and split date

17/06/2019 00:01:35 to split date from time

PS: data from excel file

Thank you :smiley:

@mz3bel

You can use replace function to replace โ€œ/โ€ with โ€œ-โ€ .

In Assign Activity

your_String= your_String.replace("/","-")

Hi @mz3bel

Assign a datetime var=strvar.toString(dd-mm-yyyy)

Ok, thank you

Hi @AshwinS2

You Sure this Query will work have a doubt on it Though. Did you try testing it.

@mz3bel

Do you want to extract date value only by skipping time values.

Eg: only 17-06-2019

@Vijay_Tulsalkar

Yea youโ€™re right , the expression tries to assign a string value to date and also .tostring(dd-mm-yyyy) is not a function of string object.

Yes @ranjith

I try to get only date

Hi @mz3bel

"7100 / 29 โ€œ.split(โ€/"c)(0) will give you 7100
"7100 / 29 โ€œ.split(โ€/"c)(1) will give you 29
cdate(โ€œ17/06/2019 00:01:35โ€).tostring(โ€œdd/mm/yyyyโ€)

@mz3bel

Try
string_output = system.Text.RegularExpressions.Regex.Match(your_String.replace("/","-"),"\b\d{1,2}-\d{1,2}-\d{4}\b").value

Hi @Vijay_Tulsalkar

the two first lines gives me this error

19.5.0+Branch.master.Sha.a03bc4726ca82b7bb3addb0d04106dc150b31fba

Source: Assign

Message: Object reference not set to an instance of an object.

Exception Type: System.NullReferenceException

As i think they donโ€™t get a valueโ€ฆ

for date i donโ€™t unterstand what you mean?

Vardate(โ€œ17/06/2019 00:01:35โ€).tostring(โ€œdd/mm/yyyyโ€) ? which by the way already a string

@ranjith

No need for regex the replace code works fine. Thank you

Up Up people :smiley:

@mz3bel

its CDate not vardate .

and what is your exact requirement. what you want to split

Ah my mistake didnโ€™t know about โ€œCDateโ€

Anyway it tells me that there that they canโ€™t convert string to date.

Because, i get the data from an excel file, than convert it to stringโ€ฆ

So i figured out how to do it, of course with some help xD

Solution :

row.Item(1).ToString.Split("/"c)(0)

row.Item(3).ToString.TrimStart(" โ€œc).Split(โ€ "c)(0)