473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Data format in application or database?

I have found that by far the easiest way to store dates in my LAMP
application is in a text string in the database in Unixtime format.

First of all, what would be the most efficient data type to store this as?

Secondly, in terms of translating into a human readable format, is it
quicker to format the date in the application using date() or in the
database in the select query?

Any thoughts?
Sep 9 '06 #1
5 1520
On Sat, 09 Sep 2006 09:40:03 +0100, in comp.lang.php turnitup
<same@same>
<45**********************@news.zen.co.ukwrote:
>| I have found that by far the easiest way to store dates in my LAMP
| application is in a text string in the database in Unixtime format.
|
| First of all, what would be the most efficient data type to store this as?
Numeric format.
>| Secondly, in terms of translating into a human readable format, is it
| quicker to format the date in the application using date() or in the
| database in the select query?
|
| Any thoughts?
Its much the much either the database server or the web server needs
to do the processing. You'll need to decide which one can carry the
load.

I prefer the database to handle such things as dates and times. They
have their own native (interal) formats for storing the data and thus
more efficient at retrieval and processing.

By storing the time as text you loose the ability to:
1. do any date/time calculations
2. restrict or delete records between date/time ranges
3. do date/time comparisons.
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Sep 9 '06 #2

turnitup wrote:
I have found that by far the easiest way to store dates in my LAMP
application is in a text string in the database in Unixtime format.

First of all, what would be the most efficient data type to store this as?

Secondly, in terms of translating into a human readable format, is it
quicker to format the date in the application using date() or in the
database in the select query?

Any thoughts?
Unless you are doing something that involves 'real-time' (as in in
relatrion to events like logging data) the Unix time stamp to me seems
to be a pain, as most of my work resolves down to the day, or in
general time of day (down to the minute). Also because of daylight
savings is factored in you may run into unexpected problems in date
calculations.

I have written up functions to convert to/from an 8 digit interger for
date recording: YYYYMMDD which as been used on earlier development
environments (like FoxBase), It does not suffer from 'when's the epoch'
or running out of seconds in 2038. That format is easy to sort by and
you can use PHP to convert it into a timestamp value if you want to do
math on it.

For time I also use an interger representing number of minutes since
midnight (1440 in a 24hour period), though not human readable it is
math friendly.

This is my preference, my reasonong is to make it generic so data can
cross between systems, but human readable enough if there is no machine
involved. Your mileage will vary on who you ask. Stick with what
works for you,

Larry

Sep 9 '06 #3
*** turnitup escribió/wrote (Sat, 09 Sep 2006 09:40:03 +0100):
I have found that by far the easiest way to store dates in my LAMP
application is in a text string in the database in Unixtime format.

First of all, what would be the most efficient data type to store this as?
What's wrong with DATE and DATETIME?
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Sep 9 '06 #4
The best way to store a date is as a DATE datatype in YYYY-MM-DD format so
you can do comparisons between different dates. How you display them to the
user is another problem. I prefer not to format any dates until as late as
possible, just before I present them to the user.

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

"turnitup" <same@samewrote in message
news:45**********************@news.zen.co.uk...
>I have found that by far the easiest way to store dates in my LAMP
application is in a text string in the database in Unixtime format.

First of all, what would be the most efficient data type to store this as?

Secondly, in terms of translating into a human readable format, is it
quicker to format the date in the application using date() or in the
database in the select query?

Any thoughts?

Sep 10 '06 #5
turnitup wrote:
I have found that by far the easiest way to store dates in my LAMP
application is in a text string in the database in Unixtime format.

First of all, what would be the most efficient data type to store this as?

Secondly, in terms of translating into a human readable format, is it
quicker to format the date in the application using date() or in the
database in the select query?

Any thoughts?
I use the DATE type that's defined in the database. That's what it's
there for.

You can format the data in almost any way you want using database
functions when retrieving the data. Additionally, you can easily
compare dates in the database.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 11 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Fabian Kr?ger | last post by:
Hello, I got a weird problem and need your help and ideas... I´ve written an php application which imports data in XML format and writes this data to a MySQL database to have a faster access....
1
by: Daman | last post by:
Hi, I am currently facing difficulty displaying chinese, japanese, russian etc. characters. I am using VB 6 and ADO to query the DB2 Version 7.2 unicode database (UTF-8). The resultset that...
3
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
2
by: JP SIngh | last post by:
Hi All We are creating a multi-region ASP application which will be using SQL Server 2000. As our users exist in multiple location i.e. UK, US, Australia how can we distinguish that the date...
11
by: Chad | last post by:
Hi Is it possible to substitute an alternative data source (eg MySQL or SQL Server) into an existing MS-Access application?
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
2
by: Dhananjay | last post by:
Hi all , I have got problem when i am tring to exportGridview Data into Excel format. It is going into text format ,but what i want is if the field is number/currency then it should go into...
6
by: Wesley Peace | last post by:
I hate to cross post, but I've gotten no answer yet on a problem I'm having with visual studio 2008. I've created a series of forms with controls to access a Access database tables. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.