SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member jake4974's Avatar
    Join Date
    Jan 2006
    Location
    Down the road, it's where I'll always be
    Posts
    357
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Formatting a date range

    I pull a date like 2006-03-04 and format it so it displays March 4th, 2006. How can I achieve March 4th - 5th, 2006?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    since you asked this in the mysql forum, i'm going to assume you want a mysql solution

    here's a start --
    Code:
    select concat(
             date_format(yourdatecol, "%M %D - ")
            ,date_format(
                date_add(yourdatecol, interval 1 day)
                              , "%D %Y")
                 ) as date_range
      from yourtable
    i shall leave it to you to work out how to trap situations over a month-end or year-end boundary
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Non-Member jake4974's Avatar
    Join Date
    Jan 2006
    Location
    Down the road, it's where I'll always be
    Posts
    357
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes I was seeking a mysql solution, good assumption (it involved assuming I knew what I was doing to a degree. That's the only questionable part )
    Thanks r-man


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
  •