Can anyone help me to filter data in a data_table extracted by data-scraping based on “date”. I need data having date less than " 1 december 2017" and discard new data greater than that date… what are the possible methods we can use
What is the format of the date you’re scraping? Is it “d MMMM yyyy”? In other words, dates like “1 December 2017”, “12 January 2020”, or “2 April 1995”?
If so, you can compare dates with the following condition in an If activity, where Row(“Date”) is the column containing your scraped date:
Datetime.ParseExact(Row("Date").ToString, "d MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture) < Datetime.ParseExact("1 December 2017", "d MMMM yyyy", System.Globalization.CultureInfo.InvariantCulture)
I got like this “6-25-2017”… when i used write csv the result was in this manner “6/25/2017” but my condition is " 1 december 2017"
To reformat your date in that format, you’ll need to set the string format. So, if
Row("Date") is the date from the CSV file formatted as “6-25-2017”, write
Datetime.ParseExact(Row("Date").ToString, "d-M-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("d MMMM yyyy")
to your datatable for the output CSV. This assumes that the format is such that 6-3-2017 could be in the file as well, rather than 6-03-2017. If it is the former format, use this one:
Datetime.ParseExact(Row("Date").ToString, "d-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("d MMMM yyyy")
sorry bro in extracted data it is like “2017-02-05” in this manner i.e year date and month.I dnt knw how it was changed to month date and year
Bro can u explain this… because i dont knw the usage of this method…
ParseExact is used to take a string and specify how it is formatted as a date. By specifying the format, we are able to convert the string into a datetime object used to compare with other dates, as well as to change the date format when output as a string
In this where i need to give my condition i.e " 1 december 2017" is in assign activity and in which manner i should give…
Thank you for answering all my question and surely this will help me…
Can u also explain the purpose of System.Globalization and CultureInfo
The condition should be in an If activity, but if you need to assign “1 december 2017” to a variable, you can use the assign activity to do that.
The CultureInfo from namespace System.Globalization specifies what culture the date is formatted in. Since most dates come from the Gregorian calendar anyway, using InvariantCulture is sufficient.
Bro im getting error.“open strict on disallows implicit conversions from ‘string’ to ‘Boolean’.”
bro if i assign “date_value”=“1 december 2017” In which position of the condition syntax i should use this date_value variable
Can you send me what you have in the If condition?
replace row(“date”).tostring with u r value i.e " 1 december 2017"