Hello
If I have a string of 16/01/2020 (within a variable) does anyone know how to convert it to read as a datetime variable as 16/01/2020?
Hello
If I have a string of 16/01/2020 (within a variable) does anyone know how to convert it to read as a datetime variable as 16/01/2020?
Thanks @YAZIDI but uipath doesn’t seem to recognize dates in the format of dd/MM/yyyy and can not do a simple conversion. That would only work if my string date was MM/dd/yyyy
Try this instead:
Date.ParseExact(YourDateVar, “dd/MM/yyyy”,System.Globalization.DateTimeFormatInfo.InvariantInfo)
Thanks - I tried putting that into a DateTime variable but still getting an error
that strange its working for me, maybe the format is incorrect try use this format: MM/dd/yyyy instead of dd/MM/yyyy
maybe you have some white spaces in your string, try using Trim before the conversion to date…
Where am I going wrong?
Variable type String
Variable type DateTime
The first date is a print of ‘RecievedDate’ variable
The second date is a print of ‘endDate’ variable. I need it to read as 16/01/2020
Can you try this?
DateTime.ParseExact(yourDate, “dd/MM/yyyy”, CultureInfo.InvariantCulture)
in here you can see it is not validated, maybe your quotes cannot be copied and pasted from here, delete them and type again…
DateTime variable always contains the Full date, you cannot cut it, but what you can do is read it as string like so: endDate.ToString("dd/MM/yyyy")