SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    date ... :S not working :S

    Well, in my user table i have a row for date of birth but when ever i put in a date it goes back to the default of "0000-00-00" :S

    the row name is user_dob, type is date, not null, default 0000-00-00...

    :S please help cause im confused as hell... im using phpmyAdmin and even when i put the date in via that it doesnt work :S no error message, just goes back to the defeault :S

    xx kieran xx

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    how are you entering the date? mysql requires that you enter the date in yyyy-mm-dd format, so if you enter it in mm/dd/yyyy it will not work.

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i entered it in like that (yyyy-mm-dd), using both phpmyadmin and my own site and neither work :S

  4. #4
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    what is the date you are entering?

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1990-03-04 :s

  6. #6
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you show your insert statement?

  7. #7
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    if the datatype is DATE then i'll bet you a doughnut that the insert statement goes like this --

    insert into ... values ( ... 1990-03-04 ... )

    well, guess what, that isn't a date, it's an arithmetic expression which evaluates to 1983, which, despite looking like a year, is an invalid date

    what you want to do is this --

    insert into ... values ( ... '1990-03-04' ... )

    notice the difference?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i deffo inserted it with 's ...

    the create code for it is ...

    CREATE TABLE `users` (
    `user_id` mediumint(8) unsigned NOT NULL auto_increment,
    `user_name` varchar(15) collate latin1_general_ci NOT NULL default '',
    `user_fname` varchar(15) collate latin1_general_ci NOT NULL default '',
    `user_lname` varchar(15) collate latin1_general_ci default NULL,
    `user_pass` varchar(32) collate latin1_general_ci NOT NULL default '',
    `user_level` tinyint(1) unsigned NOT NULL default '1',
    `user_email` varchar(40) collate latin1_general_ci NOT NULL default '',
    `user_ip` varchar(18) collate latin1_general_ci NOT NULL default '00.00.00.00',
    `user_doj` timestamp NULL default '0000-00-00 00:00:00',
    `user_dob` date NOT NULL default '0000-00-00',
    PRIMARY KEY (`user_id`),
    UNIQUE KEY `user_name` (`user_name`,`user_email`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=5 ;

  9. #9
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ahhhhhh ino whats causing it to happen ^^ but no why :S

    when i put the user_doj as now() then the user_dob doesnt work but when i dont have user_doj on now() it does work ... but why ... cause ill need to insert both at the same time, upon join ><

  10. #10
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    post the entire insert command.

  11. #11
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you know that the first TIMESTAMP column in each table is treated specially, right?

    and that this treatment differs in 4.1+ from pre-4.1, right?

    perhaps you sould just use DATETIME for user_doj and set it explicitly
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  12. #12
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937
    you know that the first TIMESTAMP column in each table is treated specially, right?

    and that this treatment differs in 4.1+ from pre-4.1, right?

    perhaps you sould just use DATETIME for user_doj and set it explicitly
    ahh, i didnt know =S

    thanks for your help guys, i can start updating my website again now

    xx kieran xx


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
  •