DateTime vs Date

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

Steve S

Since the .NET framework morphs both of these data types into being a
DATE.... that jsut happens to have both a DATE and TIME component.....
how do we tell.... which of these the data really is....... since the
same object tests out as DATE and DATETIME ?

The issue becomes one when we want to programatically create update
parameters for updating..... as there are databases that will not accept
the wrong string types..... and convert them on the fly.....
 
Both Oracle and SqlServer have DateTime types. If you are working with some
other database with specific types for Date and Time then its provider
should have types defined for it.

The ODBC provider for .Net has a System.Data.Odbc.OdbcType enum which has
values corresponding to a Date type and a Time type, so Odbc appears to
support Date and Time types - if the underlying database-specific ODBC
driver does. Ditto for the OleDB provider for .Net.

What database are you using, and what Providers and drivers?

Neil.
 
I'm using DB2... both UDB and MVS..... as datasources..... along with
other databases....... the issue comes into play when DB2 has/permits DATE
and DATETIME types.... and both of them in .NET are validated out as both
DATE and DATETIME types.... when you do TYPEOF...... hence if you try
to programmatically try to determine the proper type to set while creating
parameters..... it makes it real tough.....

The providers probably would not make a difference..... as this issue is
above the providers....
 
Steve,

Have you tried the OleDbDataReader.GetDataTypeName() method? This should
return the name of the underlying data type in the database from OleDB.

Alternatively, there is a GetSchemaTable method of the DataReader which
returns information about the query schema, including DataType (.net) and
ProviderType (database type).

These may help you to get the information you need.

Regards.
Neil.
 
THANKS.... I was trying to avoid going back for the schemas.... I know
that is an option.... and we might need to do that.... as an
alternative..... I have submitted a request to our DBAs to adopt a naming
convention for these specific types of fields... Hance I can tell from the
column name which type it is..... thanks for the suggestion
 
Back
Top