Date time type for Uipath

Is it possible robot can read format date whether 01.1.2022 and 1.1.2022?

the coding set is:
strContentTextRead.Contains(DateTime.Now.ToString(“dd.M.yyyy”)) for robot read in text file.

what I want the robot can read in content of text file if have start date and end date.

For example, start date : 1.1.2022 , end date 30.1.2022

Need your help how I should do the right coding. Thank you

Hey!

Try this:

strContentTextRead.Contains(DateTime.Now.ToString("dd.M.yyyy")) or strContentTextRead.Contains(DateTime.Now.ToString("d.MM.yyyy"))

Regards,
NaNi

@nurainfatihah.hamirruddin
welcome to the forum

DateTime.ParseExact(yourString, “d.M.yyyy”, System.Globalization.CultureInfo.InvariantCulture) will handle both

grafik
grafik

Hi @nurainfatihah.hamirruddin

How about this expression?

Use assign activity

ArrDate -> New String(){"d.M.yyyy","dd.M.yyyy","dd.MM.yyyy"}

ArrDate → Array(String) format

strContentTextRead.Contains(DateTime.ParseExact(DateTime.Now.Tostring,ArrDate,System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None))

Regards
Gokul

1 Like

(post deleted by author)

If i use this format it will come out with 00:00:00? If I want just only date without 00:00:00?

I just put or in the middle and change the format? is it true?

Hi @nurainfatihah.hamirruddin

Look into the XAML file for your reference

ArrString.xaml (11.5 KB)

Regards
Gokul

the internal structure of a datetime datatype has a time part. We do not touch the internal structure.

When doing some checks / actions with a datetime like compair two datetimes, addDays… we are working with the datetime (and its internal will be not touched).

Afterwards you can control the string representation with toString() and the format definition e.g.

In short:

  • Parse string into datetime datatype variable
  • work with the datetime variable (checks, …)
  • when another string representation is needed from the result use toString(YourNeededFormatString)

Is it true?

i’m getting error

image

feel free to do your experiments within the immediate panel
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum