How to query Date in Oracle - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to query Date in Oracle

samlow82samlow82 Posts: 2Member
I'm using Oracle and have some problem about date format.
{
Dim command As New OleDb.OleDbCommand()
command.Connection = connection
command.CommandText = "SELECT COUNT(*) AS COUNT FROM CAR WHERE DATE_KEYIN = '07/07/2003'"
Dim datRead = command.ExecuteReader()
Do Until datRead.Read = False
tb1.Text = datRead(0)
Loop
datRead.Close(
}

I saw the date that was already insert into table is in format 'M/D/YYYY', without hh:mm:ss .
But i search high and low this format is supported in Oracle.
However, it will prompt me ERROR "ORA-01843 Not a valid month"

Comments

  • raymcdraymcd Posts: 284Member
    : I'm using Oracle and have some problem about date format.
    : {
    : Dim command As New OleDb.OleDbCommand()
    : command.Connection = connection
    : command.CommandText = "SELECT COUNT(*) AS COUNT FROM CAR WHERE DATE_KEYIN = '07/07/2003'"
    : Dim datRead = command.ExecuteReader()
    : Do Until datRead.Read = False
    : tb1.Text = datRead(0)
    : Loop
    : datRead.Close(
    : }
    :
    : I saw the date that was already insert into table is in format 'M/D/YYYY', without hh:mm:ss .
    : But i search high and low this format is supported in Oracle.
    : However, it will prompt me ERROR "ORA-01843 Not a valid month"

    I always use "WHERE TO_CHAR(DATE_KEYIN, 'YYYYMMDD') = '20030707'" That's also good for sorting since it's year, month, day.

    -Ray

Sign In or Register to comment.