Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateTime to date 2

Status
Not open for further replies.

mttorpy

MIS
Feb 26, 2004
29
US
I am trying to convert a datetime field BEGIN_DATE to come out as 03/15/1994 for example. does anyone have any ideas I tried

BEGIN_DATE = convert(datetime,convert(char(10),BEGIN_DATE,101))

per a prior post but no luck as it still outputs the time

any help would be great

thanks
 
SELECT convert(Char(10),BEGIN_DATE,101)
FROM MyTable




Thanks

J. Kusch
 
Your expression converts the string back to a DATETIME value.

You can't have it both ways. If BEGIN_DATE is a column with a datatype of DATETIME, then it is always DATETIME. (I note that it must be a column, otherwise it would be @DATETIME, at least in T-SQL.)

If you need to use that string here and there then create a CHAR or VARCHAR to hold the string after you have converted the DATETIME.
Code:
DECLARE @display_date CHAR(10)
SET @display_date = CONVERT(CHAR(10), BEGIN_DATE, 101)

SELECT @display_date
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top