SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Oracle: How can omit the hour/min/sec in select statment?

    Hello,

    I have a table filled with data... with a date column...

    I want to select data for a specified date (year/month/day)... But the date column contains hour/min/sec. So when I do the fallowing:

    SELECT COUNT(*) AS total FROM AccessLog a, pr_emp e, pr_departments d WHERE a.EID = e.ID AND e.DEPT_ID = d.ID AND a.STAMP_DATE = to_date('06/12/04' ,'mm/dd/yy') AND a.ACTION = 'IN'";

    It only returns rows where hour = 00 and min = 00 and sec = 00.

    How can I solve this issue?

    Many thanks...
    Why It Doesn't Work?!

  2. #2
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the other hand, I need the solution for this problem
    Why It Doesn't Work?!

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Code:
    AND a.STAMP_DATE >= to_date('06/12/04' ,'mm/dd/yy')
    AND a.STAMP_DATE < to_date('06/13/04' ,'mm/dd/yy')
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you
    Why It Doesn't Work?!

  5. #5
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I do the fallowing (Look at +1 in bold):-

    SELECT COUNT(*) AS total FROM AccessLog a, pr_emp e, pr_departments d WHERE a.EID = e.ID AND e.DEPT_ID = d.ID AND a.STAMP_DATE >= to_date('06/12/04' ,'mm/dd/yy') AND a.STAMP_DATE < to_date('06/12/04' ,'mm/dd/yy')+1 AND (a.ACTION = 'F1' OR a.ACTION = 'F2')

    ?
    Why It Doesn't Work?!

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    i think so

    what happened when you tested it?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It worked, but I was afraid
    Why It Doesn't Work?!


Bookmarks

Posting Permissions

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