Plzzz help regarding this......

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bsonline
    New Member
    • Oct 2007
    • 21

    Plzzz help regarding this......

    I hv a datetime format like '24/01/2008 15:56:01' . Now I have to select dates from a date range, but input datetime format like 24/1/2008 15:56:01'.
    I hv written the query like :

    "select date_column from date_table where to_char(date_co lumn,'dd/mm/yyyy hh24:mi:ss') between input_date and input_date; "

    here I face a problem that when the date range within a month, it works fine.
    but when it become greater may be 2 or 6 month date range it does not work...

    Plzzz help regarding this......
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    try to use this
    [code=oracle]
    select date_column from date_table where date_column between to_char(input_d ate,'dd/mm/yyyy hh24:mi:ss') and to_char(input_d ate1,'dd/mm/yyyy hh24:mi:ss')[/code]

    Comment

    • bsonline
      New Member
      • Oct 2007
      • 21

      #3
      Originally posted by debasisdas
      try to use this
      [code=oracle]
      select date_column from date_table where date_column between to_char(input_d ate,'dd/mm/yyyy hh24:mi:ss') and to_char(input_d ate1,'dd/mm/yyyy hh24:mi:ss')[/code]
      I have get the error :.. "ORA-01722: invalid number"

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        Originally posted by bsonline
        I have get the error :.. "ORA-01722: invalid number"
        just rry to pass the inoput date in this format

        [code=oracle]
        SELECT * FROM table_name WHERE to_char(date_fi eld,'dd-mon-yyyy hh24:mi:ss') BETWEEN '01-jan-1991 01:02:03' AND '31-dec-1998 23:05:34';
        [/code]

        Comment

        • subashsavji
          New Member
          • Jan 2008
          • 93

          #5
          [code=oracle]
          Select Hiredate,to_dat e(to_char(hired ate,'dd/mm/yy Hh24:mi:ss'),'d d/mm/yy Hh24:mi:ss') From Emp
          Where Hiredate Between To_char('12-01-80','dd/mm/yy Hh24:mi:ss') And To_char(sysdate ,'dd/mm/yy Hh24:mi:ss')
          [/code]
          Last edited by debasisdas; Jan 30 '08, 11:54 AM. Reason: added code=oracle tags

          Comment

          Working...