SQL date filtering

Hello year, day, month, hour, minute, second, I have a int type. How to question them as to date format. Thanks

more ▼

asked Aug 22, 2016 at 05:48 PM in Default

avatar image


Meaning they are stored like '20160822' or something along those lines?

Aug 22, 2016 at 06:45 PM JohnM

@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.

Aug 22, 2016 at 07:52 PM Oleg
(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Aug 22, 2016 at 05:48 PM

Seen: 127 times

Last Updated: Aug 22, 2016 at 07:52 PM

Copyright 2018 Redgate Software. Privacy Policy