Date issue in php and mysql

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ricki Susic

    Date issue in php and mysql

    $result = mysql_query("SE LECT ID, tekst, date_format(dat o, '%Y %m %d') FROM
    henriks ORDER BY ID DESC LIMIT 0,3");

    Why doesn't my date show when I print the result?

    Ricki


  • Matthew Vickers

    #2
    Re: Date issue in php and mysql

    On Mon, 25 Aug 2003 12:59:19 +0200
    "Ricki Susic" <rickFJERNDETTE i@webfabrikken. net> wrote:
    [color=blue]
    > $result = mysql_query("SE LECT ID, tekst, date_format(dat o, '%Y %m
    > %d') FROM
    > henriks ORDER BY ID DESC LIMIT 0,3");
    >
    > Why doesn't my date show when I print the result?
    >
    > Ricki[/color]

    You will have to be a little more specific about "Why doesn't my date
    show...". Mabey you could copy and paste the offending code to the ng.

    Also I would probably do the query as such:

    "SELECT ID,tekst DATE_FORMAT(dat o, '%Y %m %d') as dato FROM ..."

    Matt

    --
    Quispiam Power Computing | "There are two major products that come out
    Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
    +61 2 9688 2894 | this to be a coincidence. "
    www.quispiam.com | - Jeremy S. Anderson

    Comment

    • Ricki Susic

      #3
      Re: Date issue in php and mysql

      >[color=blue]
      > "SELECT ID,tekst DATE_FORMAT(dat o, '%Y %m %d') as dato FROM ..."
      >[/color]

      Hi Matt,

      That was it! Now it works out fine. I'm a little confused though - why
      should it be necessary to define the column twice:
      DATE_FORMAT(col umn_name, '%d %m %Y') as column_name in ..........

      You know what I mean?!

      Ricki


      Comment

      • Matthew Vickers

        #4
        Re: Date issue in php and mysql

        On Mon, 25 Aug 2003 13:46:02 +0200
        "Ricki Susic" <rickFJERNDETTE i@webfabrikken. net> wrote:
        [color=blue][color=green]
        > >
        > > "SELECT ID,tekst DATE_FORMAT(dat o, '%Y %m %d') as dato FROM ..."
        > >[/color]
        >
        > Hi Matt,
        >
        > That was it! Now it works out fine. I'm a little confused though - why
        > should it be necessary to define the column twice:
        > DATE_FORMAT(col umn_name, '%d %m %Y') as column_name in ..........
        >
        > You know what I mean?!
        >
        > Ricki[/color]

        You never actually said "SELECT dato ", you asked MySQL "SELECT
        DATE_FORMAT(... )". If you didn't give the return vale from the function
        a name the column name would be"DATE_FORMAT( column_name,'%d %m
        %Y')", it should be said that you can call that column anything you like
        (except a reserved word I would guess). It is my own personal
        preference to call the return value the same name as the column you are
        passing as a parameter.

        Maybe to keep MySQL fast the developers droped out needless code which
        doesn't bother to give the return value from a function a name(i.e
        expr1, ala Access.)

        (*wipes brow* hoping the above makes some sort of sense)

        Matt

        --
        Quispiam Power Computing | "There are two major products that come out
        Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
        +61 2 9688 2894 | this to be a coincidence. "
        www.quispiam.com | - Jeremy S. Anderson

        Comment

        • Ricki Susic

          #5
          Re: Date issue in php and mysql

          [color=blue]
          > You never actually said "SELECT dato ", you asked MySQL "SELECT
          > DATE_FORMAT(... )". If you didn't give the return vale from the function
          > a name the column name would be"DATE_FORMAT( column_name,'%d %m
          > %Y')", it should be said that you can call that column anything you like
          > (except a reserved word I would guess). It is my own personal
          > preference to call the return value the same name as the column you are
          > passing as a parameter.
          >
          > Maybe to keep MySQL fast the developers droped out needless code which
          > doesn't bother to give the return value from a function a name(i.e
          > expr1, ala Access.)
          >
          > (*wipes brow* hoping the above makes some sort of sense)
          >
          > Matt[/color]
          - Jeremy S. Anderson

          I don't know if it makes sense but now I know! Thank you ;-)

          Ricki


          Comment

          • Michiel

            #6
            Re: Date issue in php and mysql

            Matthew Vickers wrote:[color=blue]
            > On Mon, 25 Aug 2003 13:46:02 +0200
            > "Ricki Susic" <rickFJERNDETTE i@webfabrikken. net> wrote:
            >
            >[color=green][color=darkred]
            >>>"SELECT ID,tekst DATE_FORMAT(dat o, '%Y %m %d') as dato FROM ..."
            >>>[/color]
            >>
            >>Hi Matt,
            >>
            >>That was it! Now it works out fine. I'm a little confused though - why
            >>should it be necessary to define the column twice:
            >>DATE_FORMAT(c olumn_name, '%d %m %Y') as column_name in ..........
            >>
            >>You know what I mean?!
            >>
            >>Ricki[/color]
            >
            >
            > You never actually said "SELECT dato ", you asked MySQL "SELECT
            > DATE_FORMAT(... )". If you didn't give the return vale from the function
            > a name the column name would be"DATE_FORMAT( column_name,'%d %m
            > %Y')", it should be said that you can call that column anything you like
            > (except a reserved word I would guess). It is my own personal
            > preference to call the return value the same name as the column you are
            > passing as a parameter.
            >
            > Maybe to keep MySQL fast the developers droped out needless code which
            > doesn't bother to give the return value from a function a name(i.e
            > expr1, ala Access.)
            >[/color]


            Thank God... (any)
            There is nothing less informative than expr1.


            [color=blue]
            > (*wipes brow* hoping the above makes some sort of sense)
            >
            > Matt
            >[/color]


            Comment

            Working...