Experts Round Table Network
Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:
Password:
Remember me
Forgot your password?
Register
Proper way to handle and store DATE in mysql
Welcome,
Guest
. Please
login
or
register
.
December 03, 2008, 03:03:49 PM
11305
Posts in
1249
Topics by
498
Members
Latest Member:
katCheeme
Home
Help
Search
Login
Register
Experts Round Table Network
|
Databases
|
MySQL
|
Proper way to handle and store DATE in mysql
« previous
next »
Pages:
[
1
]
Print
Author
Topic: Proper way to handle and store DATE in mysql (Read 434 times)
thepreacher
Offline
Posts: 78
Proper way to handle and store DATE in mysql
«
on:
April 13, 2007, 03:01:09 PM »
Say l have a date say 13 April 2007 (UK style). for the Month the actual value i am storing becomes 4 so the date is 13 4 2007. I rearrange it to yearmonthday format as that is how mysql stores dates. This date now becomes 2007413. When i store it, mysql stores it as 200-74-13. What is the right way to do this seeing that mysql uses 0000-00-00.
Secondly in the situation where i only need to store the month and year, ie 0000-00, how do i do this so that mysql will do the right thing. I use PHP BTW.
«
Last Edit: April 13, 2007, 11:19:45 PM by thepreacher
»
Logged
VGR
Mentor
Offline
Posts: 682
Re: Proper way to handle and store DATE in mysql
«
Reply #1 on:
April 15, 2007, 12:50:19 AM »
1) you forgot the leading zero for the month. Use a dat() format that pads zeroes to the left (I always use Y-m-d H:i:s)
2) just store your data appended with "-01" (a fake day) and ignore it when retrieving data
Logged
techie overlord, answers all kind of questions on
http://www.europeanexperts.org
Pages:
[
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
ERT 1.5
-----------------------------
=> Round Table Learning Center
=> Bug reports
-----------------------------
Legacy
-----------------------------
=> The next level
=> History of ERT
-----------------------------
Community Affairs
-----------------------------
=> Introductions
=> Ballot Box
===> Closed Polls
=> Soapbox
=> Propose and Consult
===> Propose and Consult...CLOSED
-----------------------------
Bits and Bytes
-----------------------------
=> Tips, Tricks, Snippets, Tidbits And General Pearls Of Wisdom
-----------------------------
Serverside Technology
-----------------------------
=> PHP
=> ASP
-----------------------------
Webservers
-----------------------------
=> Apache
=> IIS
-----------------------------
Databases
-----------------------------
=> MySQL
=> Access
=> MS SQL Server
-----------------------------
Clientside Technology
-----------------------------
=> HTML
=> CSS
=> Javascript
=> Flash
=> WAP/WML
-----------------------------
Web Technologies
-----------------------------
=> General Web Dev
=> Web Standards
=> XML
=> Online Marketing
-----------------------------
Graphics
-----------------------------
=> Graphics Design and Animation
-----------------------------
Programming
-----------------------------
=> .NET
=> JAVA
=> MS DOS Batch Scripting
=> Mathematics
=> C & C++
=> VB
=> Delphi
=> Algorithm design
-----------------------------
Operating Systems
-----------------------------
=> Windows (General)
=> NT Based (2K, 2K-03, NT, XP, Vista)
=> Open Source (All)
-----------------------------
Hardware
-----------------------------
=> Hardware General
=> Gamers Hardware (Advanced)
-----------------------------
Networking
-----------------------------
=> Home (small)
=> Office (large)
=> Internet
-----------------------------
Security
-----------------------------
=> General Security Issues
-----------------------------
Rants/Opinions/Proposals
-----------------------------
=> Site operation
Powered by SMF 1.1 RC2
|
SMF © 2001-2005, Lewis Media
Joomla Bridge by
JoomlaHacks.com