Hello year, day, month, hour, minute, second, I have a int type. How to question them as to date format. Thanks
Aug 22, 2016 at 05:48 PM
Meaning they are stored like '20160822' or something along those lines?
@Kayra There is no way that you store the date like this as int, because the year needs 4 digits, and other constituents need 2 digits each, for a total of 14. These number of digits is well outside of the integer's max value. Internally, the datetime is stored much more efficiently as a pair of integers, with left integer (4 bytes) storing the number of days from the zero date ('1900-01-01') and the right integer (4 bytes) storing the number of ticks from midnight. This explains why the datetime storage is 8 bytes. Please take a look at this question, the answer includes some elaboration and scripts related to the datetime storage. If this does not help then please provide more details about your question.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
Once you sign in you will be able to subscribe for any updates here
Answers and Comments
Need long-form SQL discussion? SQLserverCentral.com is the place.
asked: Aug 22, 2016 at 05:48 PM
Seen: 116 times
Last Updated: Aug 22, 2016 at 07:52 PM
how to change the date format of sqlserver 2005
figure out how to flag "worked 7 consecutive days" in t sql
Handling updation of datetime column with null value
Datetime formatted date converted to '1900-01-01' in temp table
Adjust date to day-before if it is a holiday
Converting numeric to datetime
Error calling MSSql Stored Proc from WebService with DateTime
Es posible configurar la manera en que SQL trata las fechas y conversiones?
Storage of DATETIME column