QuestionQ337

VerifiedUiPath Automation Development

A developer retrieves a date from an email. The date will always use the same format and will always be in the past. Examples of the format include: "3 Mar 2023", "20 Nov 2021". The variable in which the date is stored is named DateString.

Which expression should the developer use to determine whether the extracted date falls within the last 7 days?

Explanation

DateTime.ParseExact with d MMM yyyy parses a day of either one or two digits, an abbreviated month name, and a four-digit year using the invariant culture. Subtracting that parsed past date from DateTime.Today yields a TimeSpan, whose Days value can be tested for a value no greater than 7. The dd format would reject a one-digit day such as 3 Mar 2023.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!