One of the first things I need to do is get a csv cell of data into a workable date format because I am going to need to compare it to today’s date.
The cell has a format of 2019-12-30. I have been reading different things but am still unsure how I get this field into my project where I can compare to today’s date. Basically I need to see if the value is equal to today’s date minus one day.
If in your excel sheet the values are formatted as Dates then when your DataTable will also be like that and ready to use, begin your tests by reading the range and evaluating that
@Jarzzz thank you, that was very simple to get me on the right track. It converted and included the time. Wasn’t sure how to remove that part. Tried a couple examples but didn’t work. Crazy how many different posts on this subject and so many different ways to do it. It’s confusing!
From the csv I have pdate which is a string in the format 2019-12-30. I found parsing in the documentation and thought I understood that to convert I would need another variable so I created pdate_new as string.
I tried this code but still getting an error. I am using Assign Activity
“String was not recognized as a valid DateTime”
@Jarzzz thank you very very much for your easy to understand examples! I have everything working. I ended up using this for my date comparison, “Date.Today > Convert.ToDateTime(pdate_new)”
I will get A LOT of use out if this set of code. Thanks again!
Just as an added understanding, this will work only as long as the robot system time format is the same as in your csv file… the best to be sure is to use the ParseExact method…
I understand what you are saying. But in theory since your converting a time found in the CSV on the robot system, wouldn’t the converted and the current be in the same format?
Well i live in Brazil, so i come up with these types of problems all the time, since most servers are installed in English and very often carry USA format, so in my case if you send Convert.ToDateTime(“2019-12-30”) the conversion will be ok, but in case i run on a Brazilian format server, then i will get an conversion error cause system will use 30 as a month number… parseexact exists to force a format to work despite of the current system format…