My intention is to know if the data that the user has entered is a date and that it is in the MySQL ( YYYY-MM-DD
) format. First I made a query with data type date to an Excel table , but it turns out that when doing a test to see what the query managed, I could notice that the date was captured with numerical values...
Example: A date in my table is "08/16/2005" , but when I do the query, it returns a number ( 38580 in this case).
I do not understand, since it is clear that it is a date, and not a number. I know that in VB.NET we have the function IsDate
, or the Date.TryParse
... I've already tried to identify them by doing a condition, but it doesn't seem to work. How then could I do to identify if a value is of type date?
If (Not Date.TryParse(valor(0), fecha)) Then
MsgBox(valor(0))
errores += 1
End If
Excel displays dates in the format chosen by the user, but internally stores them as numeric values .
From VB.NET the function can be used
Date.FromOADate()
to obtain the date corresponding to the value delivered by Excel . ( OA=OLE Automation )To check the custom formats for date, you can go to this msdn link .