?
Solved

How do I use the CONVERT function to display a date as mm/dd/yyyy to the user when using datetime format? How do I 'trim' the time off?

Posted on 2007-12-04
3
Medium Priority
?
812 Views
Last Modified: 2010-04-21
I have a field CHARGEDATE that is a datetime format field that displays yyyy-mm-dd hh:mm:ss.xxxx

How do I display this CHARGEDATE field to users as mm/dd/yyyy (?)

I need to incorporate the CONVERT function into an SQL statement that selects records and returns a result....

For example, this statement selects records:

SELECT [ID], [BILLNUMBER], [CHARGEDATE], [LNAME], [FNAME] FROM [TABLETracking] WHERE (([CHARGEDATE] IS NOT NULL) AND ([CHARGEDATE] >= @CHARGEDATE) AND ([CHARGEDATE] <= @CHARGEDATE2) AND ([7CAT] = @7CAT))

This statement converts to yyyy-mm-dd:

SELECT CONVERT(CHAR(10), CHARGEDATE, 120), ...
FROM myTable

How do I:
1.  Incorporate this convert statement into the select statement above so I can run them all at once?
2.  Get the converted date format to show as mm/dd/yyyy   ?

thanks.....







0
Comment
Question by:jazjef
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Accepted Solution

by:
mastoo earned 2000 total points
ID: 20407040
SELECT [ID], [BILLNUMBER], Convert( varchar(10), [CHARGEDATE], 101), [LNAME], [FNAME] FROM [TABLETracking] WHERE (([CHARGEDATE] IS NOT NULL) AND ([CHARGEDATE] >= @CHARGEDATE) AND ([CHARGEDATE] <= @CHARGEDATE2) AND ([7CAT] = @7CAT))
0
 
LVL 4

Expert Comment

by:jindalankush
ID: 20409688
use it select convert(varchar,getdate(),101)
0
 
LVL 4

Author Closing Comment

by:jazjef
ID: 31427354
thanks mastoo!......
solution works great....

JJ
0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question