Extract proper date value from a text by using substring

Hi Team,

I have the below format i need the only the date and time 2019/09/13 13:34:55
I tried but not getting the proper value. Please help me out

receivedate: 2019/09/13 13:34:55

Thanks,
Sneha

1 Like

Hi @Snehamayi
Try to format your string kindlly follow this link for your reference.

cheers :smiley:

Happy learning :smiley:

3 Likes

Hi,
Thanks for your response.

No actually my requirement is I am getting the proper date and time .

I am extracting the date by using Get Text activity but I don’t want the text value I want to substring and split to get the value after “:”
i.e 2019/09/13 13:34:55

receivedate: 2019/09/13 13:34:55

Thanks,
Sneha

@Snehamayi

Do you want to store Date and Time in two different variables or what ?

Thanks…

Yes only the date and time.

1 Like

@Snehamayi

Could you please paste your input data from where you want to read Date and Time. So that we can help you how to do that.

Ya I am extracting from my mail by using Get Text activity receivedate: 2019/09/13 13:34:55

Here I need to store only the date n time not the text receivedate only the date n time.

Thanks.

Hi @Snehamayi
Use YourRecivedString.Split(cChar(":"))(1)(2)(3)(4). Or use YourRecivedString.Split(cChar(" "))(1)(2) .

1 Like

Okk…Thanks…Let em try…

@Snehamayi

Try below one:

yourStr = “receivedate: 2019/09/13 13:34:55”

yourStr.substring(yourStr.IndexOf("receivedate: ")+"receivedate: ".Length)

No I tried with both it doesnot give me result.
YourRecivedString.Split(cChar(“:”))(1)(2)(3)(4) -->this showing Error

@Snehamayi
What error it is showing?

@Snehamayi Try this

     Assign  str = "receivedate: 2019/09/13 13:34:55"
     Assign  str_date = str.Split(" ".ToCharArray)(1).ToString
     Assign  str_time = str.Split(" ".ToCharArray)(2).ToString
1 Like

Hi @Snehamayi

Use this if your desired output is : 2019/09/13 13:34:55

str.Split(" “c)(1).ToString + " " +str.Split(” "c)(2).ToString

If you want date use str.Split(" “c)(1).ToString and time use str.Split(” "c)(2).ToString

1 Like

You’ll want to convert it to a real date variable using DateParse.Exact.

It will look something like this:

DateTime.ParseExact(receivedate, "yyyy/MM/dd hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)

Then once you have a real date you can convert it into any string format you want like this for just date:

yourDate.ToString(“dd/MM/yy”)

which would output “13/09/19”

and this for just time:

yourDate.ToString(“hh:mm”)

which would output 13:34

You may have to play around with different Date Formats to get the one that’s right for you

1 Like