feri_soft Posted April 19, 2006 Share Posted April 19, 2006 how to put data into a date type field.I have no problem inputing date into a varchat field but how into a date fi eld.And how to determine the time format ? Quote Link to comment Share on other sites More sharing options...
Barand Posted April 19, 2006 Share Posted April 19, 2006 A DATE type column doesn't have a time element.[code]INSERT INTO mytable (datecol) VALUES ('2006-04-19')[/code]if you have a DATETIME column[code]INSERT INTO mytable (datecol) VALUES ('2006-04-19 21:49:00')[/code] Quote Link to comment Share on other sites More sharing options...
448191 Posted April 20, 2006 Share Posted April 20, 2006 I can recommend storing all your dates and timestamp as UNIX_TIMESTAMP. All these different time- and dateformats can get really confusing. Always use unix timestamps for al time-related operations, untill you need to display. Php's setlocale() and strftime() will then give you exactly the format you want to display. Quote Link to comment Share on other sites More sharing options...
Barand Posted April 20, 2006 Share Posted April 20, 2006 I was born in Jan, 1949. Try storing my dob in a unix timestamp. Quote Link to comment Share on other sites More sharing options...
feri_soft Posted April 21, 2006 Author Share Posted April 21, 2006 S o i must add this [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--](datecol)[/quote] i n my query ?? ;) Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 21, 2006 Share Posted April 21, 2006 [!--quoteo(post=367324:date=Apr 21 2006, 02:22 PM:name=feri_soft)--][div class=\'quotetop\']QUOTE(feri_soft @ Apr 21 2006, 02:22 PM) [snapback]367324[/snapback][/div][div class=\'quotemain\'][!--quotec--]S o i must add this i n my query ?? ;)[/quote]Barand was as clear as he could be. MySQL Date columns have no Time component. If you need a Date + time in one column then you need to use a MySQL DateTime column. You can easily alter your table structure using ALTER TABLE to modify your DATE column to a DATETIME.If you're still confused try reading this: [a href=\"http://www.gizmola.com/blog/archives/51-Exploring-Mysql-CURDATE-and-NOW.-The-same-but-different..html\" target=\"_blank\"]http://www.gizmola.com/blog/archives/51-Ex...different..html[/a] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.