split string when date and time is combined

Hi all,

I am having a string like 04/17/2019 04:16 AM.
So how to split it.I want to get only date in message box not time.
please help.

If you want only date in message box you can use :

Now.ToShortDateString It will return you the date

But if you want date from a variable which have this value
var = 04/17/2019 04:16 AM

Then u can use

var.split(" "c).first


Hi @arpita2
Try this:
str = “04/17/2019 04:16 AM”
str1 = str.Substring(0, 10)

If it’s a Date variable then you need to use only ddmmyyyy variables into ToString method:

var.split(" "c).first will fail if there will be no space between date and time values.
Check this workflow Main.xaml (4.6 KB)

system.Text.RegularExpressions.Regex.Match(“04/17/2019 04:16 AM”,“[0-9]{2}/[0-9]{2}/[0-9]{4}”).ToString

Hello @arpita2,

  1. Create a variable called strResult.
  2. Use the assign activity.
  3. left side use the variable strResult
  4.  right side use this "str.Split(" "c)(0).ToString()"

5.Use the message box to show the value which is in the strResult.

output :


thanks everyone for your support…