Select STUFF(STUFF(field,5,0,'/'),3,0,'/') As NewField
From Table Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time. NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
If you mean to a datetime field, the answer is yes. Timestamp data type has special meaning in SQL Server and it doesn't really have anything to do with datetime.
If the date and time fields are in formats (or styles) recognized by SQL Server, you can simply concantenate them and then store the result in a datetime field.
Example 1:
Declare @dt datetime
Set @dt='08/17/01' + ' ' + '06:15:30'
Select @dt
---------
Example 2:
---------
Example 3: If you need to insert the date and time delimiters.
Update table
Set datetimecol =
STUFF(STUFF(datecol,5,0,'/'),3,0,'/') + ' ' +
STUFF(STUFF(timecol,5,0,':'),3,0,':') Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time. NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
Today, Select convert(char(10), getdate(), 103) returns 17/08/2001. 103 is the style code for British/French dates. 101 returns USA style of mm/dd/yyyy. Styles 1-8, 10-12 and 14 return the year only (yy) rather than the century (yyyy).
Additional style codes are listed under CAST and CONVERT in SQL BOL and can be found at this URL.
Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time. NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.