Question

Possible Duplicate:
Should I store DateTimes as a Long (Ticks) in a database?

It is OK to use DateTime.Ticks instead of DateTime itself for implementing DateTime based operations? For example changing type of database column from DATETIME into BIGINT and then storing 123456789123456 value into it in instead of 2012-06-02 14:26:08.727?

I know in this case we've to handle conversions, but there is several pros. for example there is no limit in date-time range for storing and also we wouldn't worry about database supported types {date, datetime, smalldate} etc.

Actually I want to ensure about this approach in two field:

  1. Design Principles
  2. Performance issues

Thanks in advance.

Was it helpful?

Solution

I have voted to close as exact duplicate, but I want to give my two cents on this.
It seems like a mythical Columbus Egg, but you are looking for too much trouble for the benefit gained.

Every single access to your database that involves dates should be converted to (easy,fast) and from (not cheap) dates. But, worst of all, if, for whatever reason, you need to do maintenance work on this 'ticks' fields (without the use of your own program) you are out in the cold because you need to do all manually (conversion I mean).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top