C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

Date


Posted Date: 30 Sep 2008      Posted By: Parshuram      Member Level: Gold     Points: 1   Responses: 8



how to convert nvarchar date to date in sql
this is my string 'Aug 28 2008 5:17PM'

& i want only Year '2008'





Responses

Author: Srinivasulu    30 Sep 2008Member Level: BronzeRating: 1 out of 5     Points: 1

select convert(char(4),ColumnName,102) from TableName;

Hope this will solve your problem



Author: Parshuram    30 Sep 2008Member Level: GoldRating: 1 out of 5     Points: 1

But this code Give me Only Jan(means Month Name)


Author: Ravindra Kumar Singh    30 Sep 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi,

select Convert(char(4),current_timestamp,121)

select substring('Aug 28 2008 5:17PM',8,4)

thanks



Author: Hubli Sunil    30 Sep 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Hi.

You can write the query as follows to get the year only,

select year(cast('Aug 28 2008 5:17PM' as datetime))
or
select year('Aug 28 2008 5:17PM')



Author: Ravi Kiran Nedunuri    30 Sep 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

hi try the below one

select substring(convert(varchar,'01/01/2008',103),7,4)

for example date is o//01/2008-- the above query returns 2008

here i am taken date format as---- dd/mm/yy

Regards
N.RaviKiran



Author: Venkatesh Murali    30 Sep 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

select Convert(char(4),current_timestamp,121)


Author: Venkatesh Murali    30 Sep 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

select Convert(char(4),getdate(),121)


Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : .net
Previous : SqlServer
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use