Question

Am I missing a reason not to use the new DateTime2 datatype?

For example, might it cause problems when migrating to another database system or integrating it with another technology?

Était-ce utile?

La solution

One of the definitive articles is this from Tibor Karaszi

In favour:

  • Better precision
  • Potentially less storage

But probably best of all judging by frequency of questions here:

  • Better support for ANSI date formats (yyyy-mm-dd is not safe otherwise)

Autres conseils

If you're lucky enough to be using nothing but Sql Server 2008 and can guarantee that you will be for a long time to come, then I see no reason why you shouldn't use it if you need to.

I think the replies to this question will explain it better than I can.

However, reasons for not using it would be pretty much as you describe, i.e. it's not recognised in earlier versions of Sql Server, so moving data between the two would require some conversion.

Similarly, datetime2 has a higher precision and if you write code that depends on that level of precision, then you are locked-in to always using that datatype.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top