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("/","-")

1 Like

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.

1 Like

@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

1 Like

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)

1 Like

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