I see nobody else is willing so far to weigh in on this one. I'll give it a shot. I'd be interested in others' opinions, since I don't think this is a completely clear-cut issue.
For what's it's worth, and it's only my opinion, I don't think it's a good idea to store a date as a character string. I don't think it's a good idea to store numeric data as a character string either. I guess this really speaks to the notion of datatyping. Why do we have datatypes at all? Everything
could be stored as a string of characters, so why don't we? Wouldn't that be "simpler"?
If you've ever programmed in a typeless language (e.g. vbscript, where everything is a variant - there are other languages) and had to track down a bug because the wrong type of data ended up where it shouldn't, then you know why. It's too easy to end up with a value like '20031332' which might lie dormant in a row somewhere and bite you long after the damage is done and the trail to the offending process that created this garbage is cold. You simply cannot get such trash into a column defined with one of the datetime datatypes, thus forcing you to write much more robust systems.
Coding dates as a character string means you cannot directly utilize any of the date manipulation functions presumably provided by the RDBMS (e.g. SQL Server's dateadd, datediff, datepart, day, month, year, etc. functions). You'd either have to convert the character string to an intermediate datetime type to invoke the function, then convert it back to use it anywhere, or resort to ugly and slow character manipulation to implement the equivalent functionality.
Quote:
|
quote:I'm reluctant to use Date/Time field type since this would mean a lot of conversion and not all RDBMS stored the Date/Time in the same way
|
I don't understand how storing data in its native datatype would "...mean a lot of conversion...". To move data from one RDBMS to another would mean some sort of conversion no matter what datatypes are involved. You'd be more likely to be able to take advantage of any conversion tools provided by the vendor if you use "standard" datatypes.
Concern about client system formatting I think is a red herring; this is a presentation issue on the client, and should be dealt with at the client. The RDBMS is responsible for presenting data to the client in response to client requests. Formatting that data is a client responsibility. Any client which provides worthwhile tools for accessing an RDBMS will provide mechanisms for dealing with the datatypes that RDBMS presents.
You see many questions regarding dates because people either don't understand how a datetime datatype "works" (i.e. it stores both a date
and a time), or because they confuse data retrieval with reporting. If all you really care about is dates and have no interest in the time, it's a simple manner with a little care, to arrange for the time to be always be set to midnight everywhere, thus effectively ignoring the time altogether.
Just one man's opinion :)
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com