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

Author  Topic 

vijay1234
Starting Member

48 Posts

Posted - 2014-08-27 : 08:15:14
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.


Thanks,
Vijay

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-08-27 : 08:39:48
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-08-27 : 08:40:43
[code]DATEPART(dd,YourStampColumn)[/code]
Go to Top of Page

vijay1234
Starting Member

48 Posts

Posted - 2014-08-28 : 01:27:29
Thanks Friends.

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

:)
Go to Top of Page
   

- Advertisement -