Ads were blocked by your webbrowser.

This is not a problem, but keep in mind that developing HeidiSQL, user support and hosting takes time and money.

You may want to send a donation instead.

Year function??

pmllz's profile image pmllz posted 9 months ago in General Permalink

I am trying to answer a question as to how many trips were made in a given year, the column start_date is formatted yyyy-mm-dd 00:00:00, I am looking for how many trips were made in the year 2016. I tried using

SELECT COUNT(*) FROM trips WHERE start_date LIKE '2016%';

I am getting an answer but I am not sure this is the way to go about it, how and where would I use the YEAR() function?

arucard's profile image arucard posted 9 months ago Permalink

Not related to HeidiSQL, but try something like this:

SELECT COUNT(1)
FROM trips
WHERE start_date BETWEEN '2016-01-01 00:00:00' AND '2016-12-31 23:59:59';

Please login to leave a reply, or register at first.