Hi, I am very new to programming in visual basic. I'm working on an asp.net page and I have a value I'm pulling from a sqlserver database named "LastUpdatedDate" this is coming over as a string which I'm then trying to put into a datetime format so I can run a search for that same time in another database.
LastUpdatedDate returns "3/13/2013 4:17:01 PM" (as a string)
then I am trying to convert it a datetime field in this format "yyyy-MM-dd HH:mm" (so it will look like this:2013-03-13 16:17) using
dim mostrecentsavedate as datetime
mostrecentsavedate = DateTime.ParseExact(LastUpdatedDate, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture)
but I keep getting the "String was not recognized as a valid DateTime..." error
Any help would be MUCH appreciated.
note: I also tried running these variations with no luck:
mostrecentsavedate = DateTime.ParseExact(LastUpdatedDate, "yyyy-MM-dd HH:mm", Nothing)
mostrecentsavedate = DateTime.ParseExact(LastUpdatedDate, "M/dd/yyyy HH:mm:ss tt", CultureInfo.InvariantCulture)
I'm in Visual Basic 2012 - let me know if you need more info
LastUpdatedDate returns "3/13/2013 4:17:01 PM" (as a string)
then I am trying to convert it a datetime field in this format "yyyy-MM-dd HH:mm" (so it will look like this:2013-03-13 16:17) using
dim mostrecentsavedate as datetime
mostrecentsavedate = DateTime.ParseExact(LastUpdatedDate, "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture)
but I keep getting the "String was not recognized as a valid DateTime..." error
Any help would be MUCH appreciated.
note: I also tried running these variations with no luck:
mostrecentsavedate = DateTime.ParseExact(LastUpdatedDate, "yyyy-MM-dd HH:mm", Nothing)
mostrecentsavedate = DateTime.ParseExact(LastUpdatedDate, "M/dd/yyyy HH:mm:ss tt", CultureInfo.InvariantCulture)
I'm in Visual Basic 2012 - let me know if you need more info