Extract the day value from a date value

good afternoon i would like to extract the day value from a date value

example:
Value date: 24.09.2019 23:41
extracted value: 24

before I had left through for each, but as I am now using the framework and the queues, now I only throw the value

I hope you can help me

Hi @borismh,

By using an assign activity you could do something like: day = valuedate.Day

The Day method, when used in a date variable, will return what you need. Same with Month method :wink:

If you need to convert your value date into a date, you could always use the CDate function and pass your object in. For example: day = cdate(valuedate).day

Cheers

1 Like

@efleurent

I get this error

any ideas

@Dave

help

1 Like

Let’s assume your initial value is: string initialValue = "24.09.2019 23:41"

You can use this to extract the Date: DateTime valueDateTime = System.DateTime.Parse(initialValue, "dd.MM.yyyy HH:mm") which will return a DateTime object

From there you can extract the day with the following: string dayValue = valueDateTime.ToString("dd")

OR

You can do it all in one go with the following: string dayValue = System.DateTime.Parse(initialValue, "dd.MM.yyyy HH:mm").ToString("dd")

EDIT: I just realized I think this won’t work with VB.Net, only C#… So that’s a no-go for most all UiPath users.

1 Like

Date.ParseExact("24.09.2019 23:41", "dd.MM.yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture).Day

1 Like

@bcorrea

“24.09.2019 23:41” I want this part to be dynamic, what should I do?

Thank you very much for answering

should store this in a variable prior to passing it into the function

1 Like

i couldn’t tell, i dont know where your data is coming from…

1 Like

@bcorrea
@efleurent


is in a variable

Date.ParseExact(fecha, “dd.MM.yyyy HH:mm”, System.Globalization.CultureInfo.InvariantCulture).Day

1 Like

Change valuedate variable type to int32. The “Day” method returns an integer :slight_smile:

1 Like

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