SitePoint Sponsor

User Tag List

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

    How to select 1 record for each day?



    Hello,

    I have table with a lot of rows, with a date column, and I want to show a list of the available dates. So if I have 100 row for one day or only 1... the date will be shown once to the user.

    How can I accomplish that, please advice.

    Thank you.

    Why It Doesn't Work?!

  2. #2
    SitePoint Zealot Goldilocks's Avatar
    Join Date
    Apr 2003
    Location
    Three Bear's Cottage
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    SQL="SELECT DISTINCT column_name(s) FROM table_name"

    Obviously edit the SQL to include your own table and column names.

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

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


    It works only if the hour/min/sec is 00:00:00.

    But this is NOT the case. I have it. How can ignore them? I mean the hour/min/sec?

    Thank you.
    Why It Doesn't Work?!

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    TX
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Angry Coder


    It works only if the hour/min/sec is 00:00:00.

    But this is NOT the case. I have it. How can ignore them? I mean the hour/min/sec?

    Thank you.
    Give this a shot...
    Code:
    select  distinct left(dateColumnName, 11) from yourTable

  6. #6
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, it worked.
    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
  •