Crystal Reports & SQL Reporting Services Training Consultants
Account Log in:
Username:
Password:
Don't knock the competition
 
Institute of IT Trainers - Freelance Trainer of the Year 2006 & 2009
Liverpool Business Connect Member
  Maximum Impact Solutions Limited - Reporting Solutions, Creating Answers
Reporting Solutions - Creating Answers, Crystal Reports, Dashboarding (Xcelsius) & SQL Reporting Services

The Maximum Impact Solutions Blog Feed ME!!!!

13
May

How Do I Add a Date Feild to a Time Field in SQL?

During a recent SQL server reporting service report writing project, I had to write a number of reports where the date time of a transaction was stored in two separate date and time fields.

Solution:

There are a number of methods that one can use to achieve this, by using either the CAST or the CONVERT SQL functions.

In this instance I will be using the CONVERT function:


SELECT CONVERT( DateTime, CONVERT (Char(8), Tablename.DateField, 112) + ' ' + CONVERT( Char(8), Tablename.TimeField, 108)) AS DateTimeFieldname

FROM Table


If you have any questions, leave us a comment below, or need any assistance, please do not hesitate to Contact Us

MAKE A COMMENT

Name *

Email Address *

Comment *