SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Separate Dates by Month

    So I have the dates in my database as "2007-07-24", etc. Back from about a year or so now. I have a different format in which I want to lay out the calendar page, basically breaking it down by Month.

    It's for a comic's site and he has shows every month. So I want to be able to show about 3 months at a time:

    July - list of shows
    August - list of shows
    September - list of shows

    So I know I would need to:
    pull the current month, to check against
    query shows for current month + 1, & current month + 2

    I'm pretty sure I know how to do that. What I don't know is how to query just the month out of the date string in the database.

    Thanks in advance, help is always appreciated.

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Cambs, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use the % wildcard character, for example
    Code:
    SELECT * FROM yourtable WHERE month LIKE 2007-07%
    Jo

  3. #3
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or, use the MONTH function in MySQL. You'd also need to check the year though (with the YEAR function) to keep to this year.
    Laudetur Iesus Christus!
    Christ's Little Flock
    Jesus is the Good Shepherd


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
  •