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
ppr
(Peter Preuss)
August 2, 2022, 7:42am
3
@nurainfatihah.hamirruddin
welcome to the forum
DateTime.ParseExact(yourString, “d.M.yyyy”, System.Globalization.CultureInfo.InvariantCulture) will handle both
Gokul001
(Gokul Balaji)
August 2, 2022, 7:45am
4
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
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?
Gokul001
(Gokul Balaji)
August 2, 2022, 8:05am
9
Hi @nurainfatihah.hamirruddin
Look into the XAML file for your reference
ArrString.xaml (11.5 KB)
Regards
Gokul
ppr
(Peter Preuss)
August 2, 2022, 8:12am
10
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)
ppr
(Peter Preuss)
August 2, 2022, 9:26am
13