[thelist] SQL DB-Agnostic Date Storage

rudy r937 at interlog.com
Wed Feb 5 11:54:01 CST 2003


> So far my approach has been to use int for time fields,
> and storing all times as unix epoch time.

the problem with this is that you cannot then use sql like

   select month(datefield), count(*), sum(amount)
        from yourtable
      group by  month(datefield)

unless the database's standard date functions like month() also work on
those integers

you'd be reduced to pulling all the detail records into php and doing the
sorting, grouping, and aggregation yourself, and the performance to transfer
the detail records from the database to your script could be a killer

of course, if the database supports user defined functions, you could write
one to convert the integer back to a date, i suppose, but user defined
functions aren't always that efficient


rudy




More information about the thelist mailing list