Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2013
    Posts
    2

    Unanswered: Need to get only date from date and time format

    Hi All,

    I need an urgent help. I am trying to fetch records where a certain date field <='31-May-13'. But I get ORA-0183 Not a valid month error. Please help me.

    The Date Field is in the following format:
    'MON DD YYYY HH12:MMS":000am"'
    May 23 2013 12:00:00:000m
    and I need to put a where condition like this date_field<='31-May-2013'

    Query Used:

    Select * from table_name
    where uniq_key in ('abc','def') and fiscal_year=2013 and accounting_period=05
    and to_char(to_date(rsv_fld_30,'MON DD YYYY HH12:MMS":000am"'),YYYYMMDD) <='20130531' --- gives me ORA:0183 Not a valid month error.

    Kindly guide.

    Thanks in advance

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    The purpose of TO_DATE is to convert string datatype to DATE datatype.
    With Oracle characters between single quote marks are STRINGS!
    'This is a string, 20130531, not a date'
    When a DATE datatype is desired, then use TO_DATE() function including format.

    what datatype is RSV_FLD_30?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jul 2013
    Posts
    2
    Hi Anacedent,
    Thanks for your reply. RSV_FLD_30 is a Varchar2 data type.

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    MM is Month
    MI is Minute
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Do not ever store a date stamp in a varchar2 column. VERY VERY bad design!!.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •