Search code examples
sqldatetimestored-proceduresdatetimepicker

how to take the year using date stored in DataBase:


how to take the year using date stored in DataBase:

in Sql query ?? ????

eg date stored as

2010-04-29 15:53:09.577

how to get the year in stored procedure to check whether the year i pass and the year stored in database are same


Solution

  • That depends on the database. Try using the YEAR function.

    E.g.,

    IF YEAR(MyDateColumn) = @year ...