i have this pivot table and i need to convert it to datetime format to “MM/dd/yyyy”
this is my syntax that is not working anymore.
Assign variable ExtractedRowDate as System.DateTime =
DateTime.ParseExact(row(0).tostring.Substring(0,row(0).ToString.IndexOf(" "c)).Trim,“MM/dd/yyyy”,System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)
Error Length parameter cannot be less than zero the result is -1
i would like to read only the date row and convert it to datetime format
my initial syntax was
DateTime.ParseExact(row(0).tostring.Substring(0,row(0).ToString.IndexOf(" "c)).Trim,“MM/dd/yyyy”,System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)
which it result in parameter cannot be less than zero.
your syntax is
If(DateTime.TryParseExact(row(0).ToString, “MM/dd/yyyy”, CultureInfo.InvariantCulture, DateTimeStyles.None, Nothing),
DateTime.ParseExact(row(0).ToString, “MM/dd/yyyy”, CultureInfo.InvariantCulture),
DateTime.MinValue)
that give result to 01/01/0001 00:00:00
i need it to be in 05/05/2022 and 05/06/2022… 05 is Month 06 is day
not use to tryparse
was it meant if the row(0) is nothing
If(DateTime.TryParseExact(row(0).ToString, “MM/dd/yyyy”, CultureInfo.InvariantCulture, DateTimeStyles.None, Nothing),
then result is
DateTime.ParseExact(row(0).ToString, “MM/dd/yyyy”, CultureInfo.InvariantCulture),
Will you be able to tell me what went wrong with my initial syntax
what can i add / change to make this syntax into reading the positive?
This outcome is -1 which has error saying Error Length parameter cannot be less than zero
DateTime.ParseExact(row(0).tostring.Substring(0,row(0).ToString.IndexOf(" "c)).Trim,“MM/dd/yyyy”,System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)