Time conversion issue

Hiii,

item.Headers(“Date”)
using this I am getting date and time of the receiver
But I only want Time How to convert in uipath

Thanks and Regards,
Supriya

2 Likes

Hi @supu123

So basically by using item.Headers(“Date”) you are getting the both date and the time. So to convert this to only have the time, you can use the below command.

item.Headers("Date").ToString("hh-mm-ss”)

Additional: to get the current time, it looks like this:
System.DateTime.Now.ToString(“hh-mm-ss”)

Let know whether this helps…

1 Like

Hii @Lahiru.Fernando


For the above solution this error is shown

Thanks and Regards,
Supriya

Hi @supu123

Sorry for my late reply. This error comes when you try to directly convert the value in the header to that time format. So what you can do is… You can first assign the value to a DateTime variable first. So to do this, you need to change the type to datetime. Then use another assign statement and convert it to the time format.

I have done a sample here as shown in screenshots below.

  1. Convert the header “Date” to string and convert it to a DateTime format & assigning to a DateTime variable
    image

  2. Convert the DateTime value to String and do the formatting in the next assign activity
    image

This will work for you…

Let know how it goes… :slight_smile: