Advertisement

05.06.2008 at 03:16PM PDT, ID: 23381122
[x]
Attachment Details

Need help with syntax for T-SQL date conversion to string format

Asked by janthonyn in SQL Query Syntax, SQL Server 2005

Tags: Microsoft, SQL Server 2005, 2005, Need syntax for t-sql date conversion

This is my sql so far

declare @timestamp datetime
declare @dt varchar(20)
set @timestamp = '03-29-08 03:10:09'
select @dt = (datepart(@timestamp,yyyy))+'-'+(datepart(@timestamp,mm))+'-'+
(datepart(@timestamp,dd))

I need to figure out how to convert a timestamp in the above format to a string representation of a date like 2008-03-29. The final output must omit time and return only the date.Start Free Trial
 
Loading Advertisement...
 
[+][-]05.06.2008 at 03:19PM PDT, ID: 21511529

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.06.2008 at 03:23PM PDT, ID: 21511556

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, SQL Server 2005
Tags: Microsoft, SQL Server 2005, 2005, Need syntax for t-sql date conversion
Sign Up Now!
Solution Provided By: sbagireddi
Participating Experts: 3
Solution Grade: B
 
 
[+][-]05.06.2008 at 05:46PM PDT, ID: 21512268

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.06.2008 at 06:07PM PDT, ID: 21512407

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.07.2008 at 01:44AM PDT, ID: 21514268

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.27.2008 at 04:01PM PDT, ID: 21656430

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628