Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Date column storing time, but not displaying it

I have a oracle database backend linked to a C# Visual Studio Application.

I have a INVOICE table that stores a few Dates.

In the UI, i databind a DateTimePicker to these fields. The user selects both DATE and TIME. These values are stored to the database and are retriveable later, but i do not see the time in the Oracle interface.

C# DataSet Visualizer: enter image description here

Oracle data view enter image description here

Notice that both images are looking at the same table, first from Visual studio, and next from Oracle. The TIME is stored between sessions somewhere, as it can be retrieved and populates the user interface control which this column is bound to :

enter image description here

The problem is i want to run SQL in ORACLE and export the data to EXCEL, but since the TIME isn't visible in the ORACLE table, I cannot it for the EXCEL Report.

Is this a setting? or some weird caching issue or what?

like image 202
jordan Avatar asked Apr 17 '13 17:04

jordan


People also ask

How to display the date field in Oracle?

The date field in oracle stores date and time based on the NLS settings. In order to provide output in a specified value you can use the to_char function and provide the format in which you need to display the date field. time_out is a date field in table.

Why does Oracle's date datatype behave as both ANSI date and time datatype?

Oracle's DATE datatype behaves as both an ANSI DATE and TIME datatype. This was a design decision that only Oracle knows the reasoning for. I'll add that Oracle isn't the only RDBMS that doesn't follow ANSI SQL standards in this way. Obviously, you can remove the time portion with TO_CHAR (departure_date,'DD-MM-YYYY').

Is date column also storing time?

This tells me that date is column is also storing time. This is unexpected. Shouldn't date type discard time value like an integer type discards fractional digits?

What are the rules for using Oracle date and timestamp?

When using Oracle DATE or TIMESTAMP values, remember the following simple rules and you will probably avoid most of the common pitfalls. Both DATE and TIMESTAMP types *always* contain a date and time component. Never rely on implicit conversions of strings to dates, or dates to strings.


1 Answers

ok here is a gratuitous answer :)

please use the TO_CHAR function to return the date in your desired format.

like image 114
Randy Avatar answered Oct 22 '22 13:10

Randy