|
we are storing date into either date datatype or int datatype which one is better and why?
(comments are locked)
|
|
DATE supports date functions like DATEADD and DATEDIFF which INT does not. DATE also automatically includes validation because only valid dates are allowed. With INT you'd presumably have to add validation to validate the date values. Certainly use DATE unless you have some very good reason not to. As a matter of detail, DATE is smaller than INT (3 bytes instead of 4).
(comments are locked)
|
|
i think int datatype is batter because it occupy less space then date datatype. and we can convert it to date or datetime whenever neccessory. is it true? Surely, if INT was better then there would be no need for TIME/DATE/DATETIME types and they would not exist in SQL Server?
May 31 '10 at 12:10 PM
Fatherjack ♦♦
yes i got it, thanks man. my sir says that always store date as int so i would like to ask you why he says me like this? is there any reason behind it?
Jun 01 '10 at 01:43 AM
Dharmendra
I think that's a major error. Store the data in the data type that best reflects it. After all, we could store everything in a char field, but we don't. Numbers go in numbers fields, strings in string fields, and dates in date fields.
Jun 01 '10 at 08:48 AM
Grant Fritchey ♦♦
(comments are locked)
|

