I’m attempting to scrap a date on a webpage that is in the following format: Apr 27, 2020 . I’ve been able to save the string to a variable but I need to convert it to a true date that I can perform math on it.
Please see this or any other forum posts.
StrDate is the variable:
StrDate = StrDate.ToString("MMM dd, yyyy")
StockDateFormat should be a string. The only reason you should use a
Datetime is if you’re going to perform operations on the datetime, such as comparing it with other datetimes, adding or subtracting days, etc. If you need this functionality as well, you’ll need another variable. You cannot format the date of a datetime, as it is an object for tracking dates and times agnostic of the locale.
Hope this helps
My goal is to get the String from the website and get it into a date format that I can do operations on it.
If you need to perform operations on the date, you will not need it in format ‘Apr 27, 2020’. The Datetime object stores the days, months, and year as modifiable objects. The way this appears on screen is something you use a String variable for.
As ksrinu070184 mentions above, you can convert the string to a Datetime using
“If you need to perform operations on the date, you will not need it in format ‘Apr 27, 2020’.” - That is correct. That is the format from the website and I was attempting to convert it to a usable date format. I received a solution. Thank you for your time.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.