This discussion is archived
2 Replies Latest reply: Aug 25, 2013 6:48 AM by sb92075 RSS

comparing time in datetime field

954475 Newbie
Currently Being Moderated

Hi All,

 

I have a timestamp filed with values like:

 

8/16/2013  8:24:28 AM

 

I need to do some updated based on whether time is between 8/22/2013  8:24:28 AM and 8/22/2013  8:44:28 AM. Pls let me know can this be achieved.

 

Thanks

  • 1. Re: comparing time in datetime field
    Hoek Guru
    Currently Being Moderated

    Try something along the lines of:

     

    select *

    from   your_table_name

    where your_column_name between to_date('8/22/2013  8:24:28 AM', 'mm/dd/yyyy hh:mi:ss AM')

                                                 and to_date('8/22/2013  8:44:28 AM', 'mm/dd/yyyy hh:mi:ss AM');

     

     

    so, when you update, it'll be:

     

     

    update your_table_name

    set your_column_name = whatever_value_you_need_it_to_be

    where your_column_name between to_date('8/22/2013  8:24:28 AM', 'mm/dd/yyyy hh:mi:ss AM')

                                                 and to_date('8/22/2013  8:44:28 AM', 'mm/dd/yyyy hh:mi:ss AM');

  • 2. Re: comparing time in datetime field
    sb92075 Guru
    Currently Being Moderated

    954475 wrote:

     

    Hi All,

     

    I have a timestamp filed with values like:

     

    8/16/2013  8:24:28 AM

     

    I need to do some updated based on whether time is between 8/22/2013  8:24:28 AM and 8/22/2013  8:44:28 AM. Pls let me know can this be achieved.

     

    Thanks

     

    what is actual datatype of this column; DATE, TIMESTAMP, VARCHAR2, etc?

    the specific solution depends upon the answer to the question above.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points