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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.