Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Adds TIME portion of a DT to the DATE of another

By BuddyO,

UDF that returns a DATETIME which is the concatination of the TIME portion of one DATETIME and the DATE portion of another.
EXAMPLES:
DECLARE @Date DATETIME, @Time DATETIME
SET @Date = '7/1/03 16:00'
SET @Time = '5/16/1999 9:30 AM'
PRINT dbo.FN_AddDateTime(@Date,@Time )
RETURNS: Jul  1 2003  9:30AM

PRINT dbo.FN_AddDateTime(@Date,0)
RETURNS: Jul  1 2003 12:00AM

Total article views: 79 | Views in the last 30 days: 1
 
Related Articles
FORUM

DateTime Problem

Datetime

FORUM

Datetime Checks

Datetime Checks

FORUM

Combine overlapping datetime to return single overlapping range record

I have a set of overlapping events (datetime).I need to return a combined single event for each such...

FORUM

Conversion problem

Can't return datetime value

FORUM

datetime query issue

datetime query issue

Tags
miscellaneous    
 
Contribute