Oracle Date

G

Guest

I am not sure if I believe this myself, but here is what's happening. I created a query which pulls information from a table, and a date field is one of those fields. I user the following to change the date into a string:
to_char(last_update_dttm, 'MM/DD/YYYY HH24:MI:SS') as Last_Update_DTTM

When I run the query in TOAD, all is well with the world.

When I put the query into my ASP.Net program and I open up a data reader, I am looking at the values which are coming straight out of a "dr.GetString(6), the first 4 dates are just what I expected, then all of the sudden I get records which look like the following:

"05/28/2004\0\0\0\0\0\0\0\0\0"

As I said, when I look at these same records in TOAD, I get a real date and time. The value which should have been returned is as follows:

5/28/2004 10:35:06 AM

The date which proceed this date had the exact same date and time.

All subsequent records come back goofy was well.

Any Ideas as to what is going on>
 
D

David Sceppa

Jim,

Using version 1.1 of the .NET Framework, Microsoft's .NET Data
Provider for Oracle, and an Oracle 9i Release 2 database, I was able to run
the following code:

string strConn = "...";
OracleConnection cn = new OracleConnection(strConn);
cn.Open();

string strSQL = "SELECT TO_CHAR(SYSDATE, 'MM/DD/YYYY HH24:MI:SS') FROM
DUAL";
OracleCommand cmd = new OracleCommand(strSQL, cn);

OracleDataReader rdr = cmd.ExecuteReader();
rdr.Read();
Console.WriteLine(rdr.GetString(0));
rdr.Close();

cn.Close();

which sent "06/15/2004 14:54:58" to the Console window.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2004 Microsoft Corporation. All rights reserved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top