UiPath Automation Developer Professional v1 — Question 52
A developer has defined a variable named “CurrentDate” of type DateTime. Which of the following expressions can be used to show what hour was 12 hours prior to the date from the variable?
Answer options
- A. DateTime.SubtractHours(CurrentDate, 12).Hour
- B. CurrentDate.AddHours(–12).Hour
- C. CurrentDate SubtractHours(12).Hour
- D. DateTime.AddHours(CurrentDate, –12).Hour
Correct answer: B
Explanation
The correct answer is B, as it uses CurrentDate.AddHours(–12) to correctly subtract 12 hours from the current date and then retrieves the hour. Option A is incorrect because SubtractHours is not a valid method for DateTime. Option C is incorrect due to improper syntax, and option D is not valid since AddHours is not a static method for the DateTime class.