Trimming part of date/time variable

Hi guys,

I’m looking to trim part of my date time variable.

My variable, converted to string from an excel cell, right now shows the date/time as “11/04/2018 00:00:00”. I would like to trim the “00:00:00” part so I just have the date. How do I do this?

Thanks!

2 Likes

Hi @Spacecats7
Store that in string variable like strName and use
strName.split(" "c)(0)
you will get only date removing the rest.
If you find it useful mark it as solution.
Cheers…

Try this: .ToString.Split(" "c)(0) :slight_smile:

1 Like

Hi Buddy @Spacecats7

This usually occurs when we are trying to read the date value from excel
So this can be resolved with these steps buddy
–use excel application scope activity and pass the file path as input
–use read range activity and get the output with a datatable variable named out_dt
–use a for each row activity and pass the above variable out_dt as input
–inside this loop use a activity called assign and mention as
row(“your date columnname”) = Split(row(“your date columnname”).ToString.Trim," ")(0).ToString.Trim

so all the date value in the column which has data value will now have only the date and not the time part

Hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @Spacecats7

1 Like

@Spacecats7,

If you already know that this is Date , i would suggest you to caste it e.g DateTime.Now.ToString(“dd-mm-yy”)
this will also give you only date .

Hope it helps.

Regards,
Ahtesham

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