Go4Expert

Go4Expert (http://www.go4expert.com/)
-   SQL Server (http://www.go4expert.com/forums/sql-server-forum/)
-   -   SQL Server - Formatting Dates (http://www.go4expert.com/forums/sql-server-formatting-dates-t26441/)

duffy202 4Aug2011 21:20

SQL Server - Formatting Dates
 
Hi Guys,

I run the following query:

DECLARE @Today DATETIME; SET @Today =GETDATE()
SELECT Case.CustomerName, Case.CreatedOn
FROM MSCRM.dbo.Case Case
WHERE Case.CreatedOn BETWEEN @StartDate AND @Today
ORDER BY Case.CreatedOn


It gives the out put:
03/22/2011 8:12:17 AM Microsoft Corporation (US Date & Time)

Can anyone show me how i should ammend my code above so the output is like this:
22/03/2011 Microsoft Corporation (UK Date)

Thanks Guys,
M

sql-programs 16Aug2011 18:09

Re: SQL Server - Formatting Dates
 
Hi,

Please use the below link more date time format conversion

Time and Date Formats

We can display the date and time data in many different formats using the CONVERT function with different styles.

Example:
view plaincopy to clipboardprint?

Select getdate() Result: 2009-10-26 13:39:59.543

Different style numbers result in different formats of date time display.
Style Result
0 or 100 Oct 26 2009 1:41PM
1 10/26/2009
2 09.10.26
3 26/10/09
4 26.10.09
5 26-10-09
6 26 Oct 09
7 Oct 26, 09
8, 24, or 108 13:42:23
9 or 109 Oct 26 2009 1:42:42:543PM
10 10-26-09
11 09/10/26
12 091026
13 26 Oct 2009 13:46:14:590
14 13:46:25:967
20 2009-10-26 13:48:51
21 or 25 2009-10-26 13:48:29.340
22 10/26/09 1:48:53 PM
23 2009-10-26
24 13:48:53
101 10/26/2009
102 2009.10.26
103 26/10/2009
104 26.10.2009
105 26-10-2009
106 26 Oct 2009
107 Oct 26, 2009
110 10-26-2009

mountainman 7Feb2012 21:50

Re: SQL Server - Formatting Dates
 
Yes, i agree with above answer.


All times are GMT +5.5. The time now is 11:41.