Split string with space

I have string “24/09/2018 15:46:02” and i want only 15:46:02 please help me to solve this.

1 Like
String[] result = "24/09/2018 15:46:02".Split(" "C);
Console.Writeline(Result(1));

Split.xaml (5.1 KB)

Regards…!!
Aksh

8 Likes

@aksh1yadav thnks

Another way to do this is:

Split(“24/09/2018 15:46:02”," ")(1)

OR

If you’re getting this value earlier as a date time object, you can just use: dateTimeObject.ToLongTimeString

2 Likes

@aksh1yadav @siddharth i have csv file, contain column name date, and that date column have “24/09/2018 15:46:02” this records…
i want to update that column with only date

Hi @abhay,

I didn’t exactly get the question. You have a csv with a “date” column and column values, right? Now what is it that you want?

@abhay

use assign activity in For EachRow

row(“date”)=Convert.ToDateTime(“24/09/2018 15:46:02”).ToString(“dd-MMM-yyyy”)

hope this will help you

regards,
Pathrudu

@pathrudu @siddharth @aksh1yadav
sample1

here i want only date in 3rd column insted Date & Time

That seems doable. Use ‘Read CSV’ activity. You’ll get a datatable with all these values.
Now, just use this: Split(row(2).toString," ")(0). You’ll get the first part of your date time (which is just the date).

What activity should I use …?

After you’ve used “Read CSV” activity, use “for each” to traverse through the datatable extracted, row by row. Then THIS–Split(row(2).toString," ")(0)–returns you the exact date you need. Now it’s up to you. Whether you want to print this date (WriteLine), store it in a variable (Assign) etc etc.

The thing which you are saying is i have already done but i am facing other problem…
I want to update in the same csv file.

yourstring.tostring.split({ },stringsplitoptions)(2)

@bagishojha

In that case, did you try this:

row(2)=Split(row(2).toString," ")(0)

Once it has been done for all the dates, use Write CSV.

Let me know if this resolves your problem.

2 Likes

@siddharth
Then it will create new CSV not update the older one

what problem, you are facing

How does that matter as long as all your previous values that you require are there, just the dates have been updated?

I have an csv file

now i want to update the column which contains date and time to only date…

plz explain it properly