Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Storing dates as an Integer

Author  Topic 

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2004-11-29 : 13:17:35
Hi guys. Currently I'm working on a database conversion 2 personnel systems. In the old system they store peoples birthdates with an integer column. Some of the birth dates are invalid (for example someone had a value of 0 for their birthdate), so I had to use the IsDate function to convert bad birthdates to a "default" birthday. It seems to me that it would of been easier to do the data conversion if the old system used a date/time column for the birthdate field.

From reading BOL it says that SQL Server stores dates as 2 integers so other than saving storage space why would anyone want to use an integer column to store dates??

Dustin Michaels

X002548
Not Just a Number

15586 Posts

Posted - 2004-11-29 : 13:25:33
because they believe they are rocket scientists...

What do the Numbers look like?

Like this?

DECLARE @x datetime
SELECT @x = '1/1/1970'
SELECT CONVERT(Int,@x)





Brett

8-)
Go to Top of Page

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2004-11-29 : 13:31:00
The numbers where in this form yyyymmdd. After I converted all the bad dates to some default value then the information was converted over with one query.
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-11-30 : 12:28:27
probably it was easier for them to query numbers than dates? like you don't have to use datediff to add or subtract dates from one another, you'll get equal length.



--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -