Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2002
    Location
    Cochin, INDIA
    Posts
    9

    Unanswered: Retrieving a record w.r.t a Date Field Value

    Hi,
    I have a table(Log) with the following structure:

    TIMESTAMP NOT NULL DATE
    USERID VARCHAR2(16)
    ACTION NOT NULL NUMBER(2)
    DETAILS VARCHAR2(36)

    Insertion of data is achieved using the following SQL:

    INSERT INTO userlog(TIMESTAMP, USERID, ACTION, DETAILS) VALUES (to_date('11/01/02 03:27:56 PM','MM/DD/YY HH:MIS AM'), 'SAJ002', 1, 'DEFAULT LOGGING')


    Now I want to retrieve the records with TimeStamp between 11:30 AM and 2:30 PM on a day, how do I achieve the same?

    Thanks in advance,
    Saju Joseph

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Retrieving a record w.r.t a Date Field Value

    Originally posted by peruvachira
    Hi,
    I have a table(Log) with the following structure:

    TIMESTAMP NOT NULL DATE
    USERID VARCHAR2(16)
    ACTION NOT NULL NUMBER(2)
    DETAILS VARCHAR2(36)

    Insertion of data is achieved using the following SQL:

    INSERT INTO userlog(TIMESTAMP, USERID, ACTION, DETAILS) VALUES (to_date('11/01/02 03:27:56 PM','MM/DD/YY HH:MIS AM'), 'SAJ002', 1, 'DEFAULT LOGGING')


    Now I want to retrieve the records with TimeStamp between 11:30 AM and 2:30 PM on a day, how do I achieve the same?

    Thanks in advance,
    Saju Joseph
    Assuming day to be 01 Oct 2002:

    SELECT * FROM userlog
    WHERE timestamp BETWEEN TO_DATE('10/01/2002 11:30 AM','MM/DD/YYYY HH:MIS AM') AND TO_DATE('10/01/2002 02:30 PM','MM/DD/YYYY HH:MIS AM');

Posting Permissions

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