Date vs DateTime

  • Thread starter Thread starter Steve S
  • Start date Start date
S

Steve S

If BOTH of these types respond with DateTime ........

Dim da As Date = Today
Dim dt As DateTime = Now
If dt.GetType.Name = "Date" Then
MsgBox("dt date")
End If
If dt.GetType.Name = "DateTime" Then
MsgBox("dt datetime")
End If

If da.GetType.Name = "Date" Then
MsgBox("da date")
End If
If da.GetType.Name = "DateTime" Then
MsgBox("da datetime")
End If

AND IF.......

Dim da As Object = Today
Dim dt As Object = Now

If TypeOf da Is Date Then
MsgBox("DA is DATE")
End If
If TypeOf da Is DateTime Then
MsgBox("DA is DATETIME")
End If
If TypeOf dt Is Date Then
MsgBox("DT is DATE")
End If
If TypeOf dt Is DateTime Then
MsgBox("DT is DATETIME")
End If

shows that they confirm out to be BOTH (ie probably all inherited from the
same base class situation)....... how does one tell which type of object
they should be declaring a parameter to be.... when they are updating the
database with a command ?

OR... is MS saying that the adapters must always be tightly bound to the
database for situations like this ?
 
shows that they confirm out to be BOTH (ie probably all inherited from the
same base class situation)....... how does one tell which type of object
they should be declaring a parameter to be.... when they are updating the
database with a command ?

I believe Date is just an alias for DateTime, really - it shouldn't
matter which is used where.
 
While your statements are true when it comes to using these objects in
memory, it does make a difference when you are specifing them as parameters
for adapter commands........
 
Steve S said:
While your statements are true when it comes to using these objects in
memory, it does make a difference when you are specifing them as parameters
for adapter commands........

Could you give an example of this? If you could give an example which
needn't actually run, but which I can compile, that would be very
helpful.

Note that the .NET types and the DbType enumerations are entirely
distinct things. It clearly makes a difference whether you specify that
a parameter is of type DbType.Date or DbType.DateTime, but that's a
different matter.
 
After much review today.... we have isolated the underlying issue to
this.... The parameter that is used for the COMPAIR in the WHERE portion of
the update/delete commands are causing the real issue... we have worked
around all the other issues and have come to accept the fact that we are
only going to be 95% accurate on the actual type calls.....

The rest of them we are going to need to rely on the programmers to provide
us with the proper type for the field they are requesting and HOPE the
database will take care of us.....

The reason why the WHEREs will not handle our DateTime is that the database
holds accurate information down to the 6th sig decimal figure on the
second.... and ADO seems like it only holds information down to the THIRD.
Therefore if we are dealing with a record that was created by another system
and a DateTime field was set by the other application, it is possible that
the value is down to the 6th figure.... hence ours will never match the
information. OOPS.....

ALOHA
 
Back
Top