[thelist] UNIX Timestamp versus the DateTime Field

R.Livsey R.Livsey at cache-22.co.uk
Fri Apr 12 19:17:01 CDT 2002


> Lately, or may be I've just been paying closer attention,
> there has been a lot of discussion about using UNIX
> Timestamps in place of the DB provided date fields in a database.
>
> The consensus (consensi? ;-) of the people answering
> questions appears to be leaning towards using UNIX
> Timestamps. Am I the only one that thinks this is "wrong" or
> problematic?
>
>   - You can't calc dates before 1970 with the UNIX Timestamp.
>   - You can't calc dates after 2023 with the UNIX Timestamp.
>   - There are no (or limited) SQL functions for UNIX Timestamp.
>
> Why are people making (in my opinion) more work for
> themselves by using a non-"DB"-standard date format in their tables?
>
> What about adding One Year to the Date Field?
>    (My Answer) UPDATE TABLE Set DateField = DateAdd('yy',1,DateField)
>
> There is more, but I hope this makes my point.
>
> Displaying the date to the user is a whole n'ther story. But
> if you are going to be using your DB "properly", why are you
> forcing it (and you ) to do more work than it has to.
>
> Or am I just being cranky??
> ---
> Anthony Baratta

Not at all. Has to be said that the main reason I use Unix timestamps is
because I always have done before I started using databases.

At the moment in my blog thing Im storing a value for month and one for
year in the db so I can say 'SELECT whatever FROM table WHERE month=1
AND year=2002'. V bad way of doing it and I can see that it would be
much better to store the date so I can get mySQL to do it for me! I
think that's a definite change Im going to make over the next week or so
(workload allowing).

Depends on the situation I suppose. In the case above, I probably should
have used the date field as opposed to hacking my way around the problem
of how to get all entries from year 'y'

One possible converted programmer here :)
--
R.Livsey




More information about the thelist mailing list