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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Geting the date part only

Author  Topic 

BendJoe
Posting Yak Master

128 Posts

Posted - 2010-04-26 : 12:26:02

How can I get the date part only from my table
convert(varchar,(DATEPART(year,mydate))+'/'+Convert(varchar, DATEPART(month,mydate))+'/'+ Convert(varchar,DATEPART(day, mydate))
this is not working.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-26 : 12:27:25
SELECT CONVERT(varchar(10), someDateTimeColumn, 101)
FROM ...

But if this is just for display purposes, then you do this in your application and not in T-SQL.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

BendJoe
Posting Yak Master

128 Posts

Posted - 2010-04-26 : 12:31:59
quote:
Originally posted by tkizer

SELECT CONVERT(varchar(10), someDateTimeColumn, 101)
FROM ...

But if this is just for display purposes, then you do this in your application and not in T-SQL.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog


It is for a SSRS report.I know how to do this in C#.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-26 : 12:38:56
You can format directly in SSRS then. You do not need to (and should not) do the formatting in T-SQL.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-27 : 00:45:58
quote:
Originally posted by BendJoe

quote:
Originally posted by tkizer

SELECT CONVERT(varchar(10), someDateTimeColumn, 101)
FROM ...

But if this is just for display purposes, then you do this in your application and not in T-SQL.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog


It is for a SSRS report.I know how to do this in C#.


If for ssrs, just right click on textbox showing date value choose textbox propertis then in format tab chose option without time part from standard formats available.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -