SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bandi
Flowing Fount of Yak Knowledge

India
2224 Posts

Posted - 02/19/2013 :  08:22:55  Show Profile  Reply with Quote
DECLARE @table TABLE(value NVARCHAR(30), fieldName Varchar(10))
INSERT INTO @table VALUES('Jan 29 2013 12:00AM', 'pur_date'), ('afvajfab', 'sft_name')
SELECT
CASE WHEN fieldName = 'pur_date' THEN need mm/dd/yyyy
ELSE value END
FROM @table

i want output in the format of mm/dd/yyyy

Note: while unpivoting values i have changed datetime column to Nvarchar ( it must need for me)..
Now i want above format for display..


How to do that? please help me

--
Chandu

Edited by - bandi on 02/19/2013 08:31:54

James K
Flowing Fount of Yak Knowledge

3760 Posts

Posted - 02/19/2013 :  08:44:14  Show Profile  Reply with Quote
DECLARE @table TABLE(value NVARCHAR(30), fieldName Varchar(10))
INSERT INTO @table VALUES('Jan 29 2013 12:00AM', 'pur_date'), ('afvajfab', 'sft_name')
SELECT 
CASE WHEN fieldName = 'pur_date' THEN CONVERT(VARCHAR(32),CAST([value] AS DATETIME),101)
ELSE value END
FROM @table
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8768 Posts

Posted - 02/19/2013 :  08:44:41  Show Profile  Visit webfred's Homepage  Reply with Quote
DECLARE @table TABLE(value NVARCHAR(30), fieldName Varchar(10))
INSERT INTO @table VALUES('Jan 29 2013 12:00AM', 'pur_date'), ('afvajfab', 'sft_name')

SELECT
CASE WHEN fieldName = 'pur_date' THEN convert(varchar(10),convert(datetime,value,100),101)
ELSE value END
FROM @table



Too old to Rock'n'Roll too young to die.
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2224 Posts

Posted - 02/19/2013 :  09:28:14  Show Profile  Reply with Quote
Thank you

--
Chandu
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2165 Posts

Posted - 02/19/2013 :  09:29:51  Show Profile  Reply with Quote
obligatory "format in front end" comment here...








How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8768 Posts

Posted - 02/19/2013 :  09:50:46  Show Profile  Visit webfred's Homepage  Reply with Quote
quote:
Originally posted by DonAtWork

obligatory "format in front end" comment here...






How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx






it was about time

cheers

Too old to Rock'n'Roll too young to die.

Edited by - webfred on 02/19/2013 09:51:09
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000