SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 29 of 29
  1. #26
    SitePoint Evangelist
    Join Date
    Dec 2003
    Location
    uk
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Ok Got it sorted now :-)
    It just needed the AS bit; below is the full query:


    $result = mysql_query("SELECT destination, DATE_FORMAT(departureDate, '%d/%m/%Y') as formattedDate FROM entries WHERE departureDate >= '$dep3' and DepartureDate <= '$dep3' + INTERVAL '7' DAY

    ");


    Thanks for your help and advise :-)

  2. #27
    SitePoint Evangelist
    Join Date
    Dec 2003
    Location
    uk
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    I got it sorted now :-)

    It just needed the AS part

    this is the query:

    $result = mysql_query("SELECT destination, DATE_FORMAT(departureDate, '%d/%m/%Y') as formattedDate FROM entries WHERE departureDate >= '$dep3' and DepartureDate <= '$dep3' + INTERVAL '7' DAY

    ");


    Many thanks for your help and advice :-)

  3. #28
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,031
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    You don't need the AS part, you can also do

    PHP Code:
    $result mysql_query("SELECT destination, DATE_FORMAT(departureDate, '%d/%m/%Y') FROM entires WHERE departureDate >= '$dep3' AND departureDate <= '$dep3' + INTERVAL '7' DAY");
    while(
    $row mysql_fetch_assoc($result))
    {
      echo 
    $row['DATE_FORMAT(departureDate, \'%d/%m/%Y\')'];

    But as you can see, that's rather hard to read, and you have to change the PHP if you ever change the date format.
    So it's easier to use "AS formattedDate" and then use $row['formattedDate']


  4. #29
    SitePoint Evangelist
    Join Date
    Dec 2003
    Location
    uk
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    ok thanks

    I ll bear that in mind :-)


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
  •