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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to extract date portion from time stamp column
 New Topic  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

2681 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

3865 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  
 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.17 seconds. Powered By: Snitz Forums 2000