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 2008 Forums
 Transact-SQL (2008)
 How to extract date portion from time stamp column
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

48 Posts

Posted - 08/27/2014 :  08:15:14  Show Profile  Reply with Quote
Hi all,

i have a time stamp column whose format is (yyyy-mm-dd)2013-10-07 05:51:38.410

I would want to extract only date(dd) part from the above.

Kindly provide me the query friends.


Flowing Fount of Yak Knowledge

2780 Posts

Posted - 08/27/2014 :  08:39:48  Show Profile  Reply with Quote
If the column is type datetime:

select datepart(day, timestampcolumn)

if the column is type varchar:

select datepart(day, cast(timestampcolumn as datetime))

Go to Top of Page

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 08/27/2014 :  08:40:43  Show Profile  Reply with Quote
Go to Top of Page

Starting Member

48 Posts

Posted - 08/28/2014 :  01:27:29  Show Profile  Reply with Quote
Thanks Friends.

select CONVERT(VARCHAR(10), DAY(Getdate()), 112) is what i've tried.

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