| Author: Srinivasulu 30 Sep 2008 | Member Level: Bronze | Rating: Points: 1 |
select convert(char(4),ColumnName,102) from TableName;
Hope this will solve your problem
|
| Author: Parshuram 30 Sep 2008 | Member Level: Gold | Rating: Points: 1 |
But this code Give me Only Jan(means Month Name)
|
| Author: Ravindra Kumar Singh 30 Sep 2008 | Member Level: Gold | Rating:  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 2008 | Member Level: Diamond | Rating:  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 2008 | Member Level: Gold | Rating:  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 2008 | Member Level: Gold | Rating:  Points: 2 |
select Convert(char(4),current_timestamp,121)
|
| Author: Venkatesh Murali 30 Sep 2008 | Member Level: Gold | Rating:  Points: 2 |
select Convert(char(4),getdate(),121)
|