How To Combine Two Data Columns?
i have this SQL statement I want to combine 'date' and 'dayOfWeek' Column SELECT CONVERT(date,startTimeStamp) AS DATE , datename(dw,CONVERT(date,startTimeStamp)) as dayOfWee
Solution 1:
Sounds like you want this:
SELECT CONVERT(date,startTimeStamp) AS DATE
, datename(dw,CONVERT(date,startTimeStamp)) as dayOfWeek
,cast(datename(dw,CONVERT(date, startTimeStamp)) as varchar(50)) -- add this
+ ' ' + -- add this
CONVERT(varchar(50),CONVERT(date,startTimeStamp)) FullDate -- add this
,CONVERT(time,[startTimeStamp])AS StartTime
,CONVERT(time,[endTimeStamp])AS EndTime
,DATEDIFF(HH,[startTimeStamp] ,[endTimeStamp])
FROM [TaskManagementSystem_DB].[dbo].[Timesheet_entry]
To concatenate the fields together you must cast()
them to the same datatype, similar to this:
select cast(datename(dw,CONVERT(date, getdate())) as varchar(50))
+ ' ' +
CONVERT(varchar(50) ,getdate()) newdate
Post a Comment for "How To Combine Two Data Columns?"