Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Convert varchar back into datetime??
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

66 Posts

Posted - 04/24/2013 :  12:19:50  Show Profile  Reply with Quote
Hello -

I have a column in my View script that I convert to varchar(10) and want to convert it back to a date for the output to be in excel. Here is the original line

CONVERT(VARCHAR(10), d.DocDate, 110) AS [Invoice Date]

I have tried this line with no luck.

CONVERT(VARCHAR(10), CONVERT(DATETIME, d.DocDate), 110) AS [Invoice Date]

Can someone confirm if I have the right lines in the sql liine? Or I'm open to another way of writing it out.

Thank you

Flowing Fount of Yak Knowledge

4614 Posts

Posted - 04/24/2013 :  12:26:18  Show Profile  Reply with Quote
CAST([Invoice Date] AS DATE)
CONVERT(DATETIME, [Invoice Date], 110)

--Edit: forgot this was 2005.

Edited by - Lamprey on 04/24/2013 12:27:40
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 04/24/2013 :  13:01:38  Show Profile  Reply with Quote
why not do this if attempt was to strip off timepart?


format you can always get in way you want at front end by applying format functions

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000