A
A
avp2017-01-03 15:48:38
SQL
avp, 2017-01-03 15:48:38

How to select unique years from field with Date type?

How to select unique years from field with Date type?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey Skorzhinsky, 2017-01-03
dnepr @avpdnepr

select datepart(yyyy, dtField) from table group by datepart(yyyy, dtField) having count(*)=1

A
Alexander Evgenievich, 2017-01-03
@banderos120

SELECT DATE_FORMAT(e.start, '%y') AS year FROM events e GROUP BY year;

S
Swartalf, 2017-01-03
@Swartalf

SELECT DISTINCT(DATE_FORMAT(e.start, '%Y')) AS year FROM events e

R
rll, 2017-01-24
@rll

select distinct year(dat) from table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question