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.
| Author |
Topic |
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2010-05-27 : 04:28:51
|
| i want to storage datetime as :DATETIME 8 bytesOrbigint 8 Bytesboth of 8 byteswill there be diffrence in the Index size? in performance? ThanksPeleg |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-05-27 : 04:39:03
|
I always would store a datetime value as a datetime data type.I don't see any reason to convert it to anything else. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-05-27 : 04:44:42
|
| DATETIME is understood, by SQL, as being ... ermmmm ... a Date+Time. BigInt isn'tSo with DATETIME you can use functions which understand dates - Years, Months, Days, Hours, Minutes, seconds etc.You can get everything in the last year (without having to worry about leap years etc). Everything yesterday (from midnight-to-midnight). And so on ...... and the ability to Format the value in any human-readable format you like.Annoys me having to do CONVERT(varchar(24), DATEADD(Second, SomeDateColumnFromOracle, '19700101')) just to see what an integer "date-time" actually is.Much more tedious using BigInt. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-05-27 : 05:02:05
|
Even if using BigInt uses less storage and gives better performance, with the current computing power and cheap disk space, the different might be just marginal. As Kristen as shown, the ease of coding and maintainability out weight that. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2010-05-27 : 07:52:29
|
It depends on your requirements.If only seconds are stored, use DATETIME2(0) which uses only 6 bytes with the range of 0001-9999 for years. N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|
|
|