Food for thought:
SELECT DATEDIFF(millisecond,'20150521','20150522') --86400000 ms in a day
SELECT
RightNow, RightNowNumeric, RightNowDecimalPart, RightNowIntegerPart,
ReconstructedDate = DATEADD(day,RightNowIntegerPart,0),
ReconstructedDateTime = DATEADD(millisecond,86400000*RightNowDecimalPart,DATEADD(day,RightNowIntegerPart,0))
FROM (
SELECT
RightNow,
RightNowNumeric = CAST(RightNow AS NUMERIC(18,12)),
RightNowDecimalPart = CAST(RightNow AS NUMERIC(18,12))%1,
RightNowIntegerPart = CAST(CAST(RightNow AS NUMERIC(18,12)) - CAST(RightNow AS NUMERIC(18,12))%1 AS INT)
FROM (
SELECT RightNow = GETDATE()) d
) e
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden