UiPath Automation Developer Professional v1 — Question 159
Which expression correctly converts the string variable “DateString” with the value “03/03/2023 16:23:11” into a Date Time variable?
Answer options
- A. DateTime.ParseExact(DateString, “mm/dd/yyyy HH:mm:ss”, CultureInfo.InvariantCultue}
- B. DateTime.ParseExact(DateString, “dd/MM/yyyy HH:mm:ss”, CultureInfo.InvariantCulture}
- C. DateTime.ParseExact(DateString, “dd/MM/yyyy hh:mm:ss”, CultureInfo.InvariantCulture}
- D. DateTime.ParseExact(DateString, “MM/dd/yyyy hh:mm:ss”, CultureInfo.InvariantCultue}
Correct answer: B
Explanation
The correct answer is B because it uses the correct format 'dd/MM/yyyy HH:mm:ss' that matches the input string '03/03/2023 16:23:11', where '03' is the day and '16' is the hour in 24-hour format. Options A, C, and D incorrectly use formats that do not correspond to the provided date string, such as 'mm' for minutes instead of 'dd' for days, or using 'hh' for hour, which is not suitable for 24-hour time.