This blog is most useful for Software Engineers, Database Administrators, QA and etc.
Jan 29, 2009
Jan 21, 2009
How to Combine Date & Time in SQL
/*
=================================================================
== PROCEDURE: COMBINE_DTM
==
== PURPOSE:Combines a date and time into a datetime result
==
== CREATED:Friday, October 3, 2008 @ 1:24:00 AM
==
== TYPE:APP
=================================================================*/
CREATE FUNCTION [dbo].[COMBINE_DTM] (
@inDATE_DTM AS datetime,
@inTIME_DTM AS datetime
) RETURNS datetime
AS
BEGIN
RETURN
CAST((ROUND(CAST(@inDATE_DTM AS float), 0, 1) ) AS float) +
(CAST(@inTIME_DTM AS float) - (ROUND(CAST(@inTIME_DTM AS float), 0, 1)) + .00000001)
END
use this links to original links
http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/thread/ee161d81-8f04-4328-b2a8-a32f95c30b29/
or
http://blogs.msdn.com/patrickgallucci/archive/2007/11/18/sql-server-function-to-merge-a-date-with-a-time.aspx
=================================================================
== PROCEDURE: COMBINE_DTM
==
== PURPOSE:
==
== CREATED:
==
== TYPE:
=================================================================*/
CREATE FUNCTION [dbo].[COMBINE_DTM] (
@inDATE_DTM AS datetime,
@inTIME_DTM AS datetime
) RETURNS datetime
AS
BEGIN
RETURN
CAST((ROUND(CAST(@inDATE_DTM AS float), 0, 1) ) AS float) +
(CAST(@inTIME_DTM AS float) - (ROUND(CAST(@inTIME_DTM AS float), 0, 1)) + .00000001)
END
use this links to original links
http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/thread/ee161d81-8f04-4328-b2a8-a32f95c30b29/
or
http://blogs.msdn.com/patrickgallucci/archive/2007/11/18/sql-server-function-to-merge-a-date-with-a-time.aspx
Subscribe to:
Posts (Atom)