Share via

Date Function

SAQ 21 Reputation points
2021-07-14T08:37:22.63+00:00

Create a field in Table Colum:- tbl_inst_install_date Data Type -----varchar(50) Date 03/02/2016

No, I want to Convert this Colum Date from 03/02/2016 to 2016 (dd/mm/yyyy) To (YYYY)

Kindly Advise us

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

Answer accepted by question author

MelissaMa-msft 24,246 Reputation points Moderator
2021-07-14T08:54:29.357+00:00

Hi @SAQ ,

Welcome to Microsoft Q&A!

Please refer below:

select year(cast(yourcolumn as date)) from yourtable  

select format(cast(yourcolumn as date),'yyyy') from yourtable  

select  right(yourcolumn,4) from yourtable  

Best regards,
Melissa


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.