Hi, I'm trying to change the date on this query. USE [adventureworks2008r2] GO SELECT p.Title, p.PersonType , p.NameStyle , p.FirstName , p.MiddleName , p.LastName , p.ModifiedDate, pp.PhoneNumber , pp.PhoneNumberTypeID, pe.EmailAddress, Pe.ModifiedDate FROM Person.Person AS p JOIN Person.PersonPhone AS pp ON p.BusinessEntityID = pp.BusinessEntityID Join Person.EmailAddress As Pe on p.BusinessEntityID = pe.BusinessEntityID
Hi You could either use [CAST] expression for each of the date\time fields Or the [SET DATEFORMAT] at the start of the query. Personal I use prefer to us CAST, especially if you are just wanting to change the output. :
http://msdn.microsoft.com/en-us/library/ms187928.aspx : http://SET+DATEFORMAT
If you have to do the formatting in T-SQL, I think @sp_lock has the answer. But, formatting is not something that T-SQL does well. Generally, I suggest that people rely on the client applications or reporting tools for formatting. They do a much better job of it.