Results 1 to 7 of 7

Thread: MySQL: Data as Date

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    MySQL: Data as Date

    How do you enter a date into a MySQL field? I've been trying to do it like this:

    PHP Code:
    date("Y-d-m"
    But it keeps coming out as: 0000-00-00
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    I tend to do mine like so:

    PHP Code:
    $date date("Y-d-m");
    mysql_query("insert into tableName (completeDate) values ('$date')"
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  3. #3

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    This doesn't help me at all.

    I just can't figure this out
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    make sure the field type varchar and not int
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  5. #5

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    the field is date
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    oh. I always used varchar and never had any problems, and I have no idea how date works.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  7. #7

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: MySQL: Data as Date

    I just realized I had the format wrong. It needs to be:

    PHP Code:
    date("Y-m-d"
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width