Converting datetime value into year value

  • How do I convert a datetime value into just the 4 digit year?

  • You can use DATENAME function to do this.  This will do it for the current date.

    SELECT DATENAME( year, GetDate() )

    Or in a query

    SELECT DATENAME( year, <ColumnName> )

    FROM <TableName>

    Where Column name is the name of the column and Table name is the name of the table.

    Andez

  • Or simply

    SELECT YEAR(MyField) FROM MyTable


    N 56°04'39.16"
    E 12°55'05.25"

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply