Removing time from SQL datetime

How many times do you have a data point in your application that is a date but not a datetime? For example:  birthdate, receiptdate, licensedate, etc.  Things can get really weird when doing date math if these “dates” have times on them – for example:  2.33333 years instead of 2.32.   We have even seen some strange things happen with timezones - 8/2/1955 00:00 becomes 8/2/1955 01:00 (still puzzled by this one although I have seen it a few times).

Kevin explores some solutions to this problem in our latest team blog post.

The one option I have seen several clients use on projects is to store the date as a varchar(8) in YYYYMMDD format.  While the ISO formatting does allow sorting, it just feels icky.

 

Jonathan Cogley is the CEO of Thycotic Software, an agile software services and product development company based in Washington DC.  Secret Server is our flagship web-based password management product.

No Comments