Exam UiPath-ADPv1 Topic 1 Question 163 Discussion

Actual exam question for UiPath's UiPath-ADPv1 exam
Question #: 163
Topic #: 1
How do you subtract a specific TimeSpan from "Today" in VB.NET?

Suggested Answer: D Vote an answer

The Today property of the DateTime structure returns the current date with the time component set to zero1. The Subtract method of the DateTime structure returns a new DateTime object that is the result of subtracting a specified time interval from this instance2. The TimeSpan structure represents a time interval that can be expressed in days, hours, minutes, seconds, and milliseconds3.
Option D is the correct way to subtract a specific TimeSpan from Today in VB.NET. For example, the following code snippet subtracts one day and two hours from the current date and displays the result:
Dim ts As New TimeSpan (1, 2, 0, 0) ' One day and two hours
Dim result As DateTime = Today.Subtract (ts) ' Subtract from Today
Console.WriteLine (result.ToString ("d")) ' Display the result
Option A is not valid, because there is no SubtractSpanFrom method in the DateTime structure. Option B is not correct, because it subtracts the TimeSpan from the current date and time, not just the date. Option C is not valid, because there is no SubtractUsingDate method in the DateTime structure.
References: 1: DateTime.Today Property (System) 2: DateTime.Subtract Method (System) 3: TimeSpan Structure (System)

by Frederica at Mar 25, 2025, 03:42 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10