Hi is it possible to count days between columns, something like

datediff(date_finished-date_started) as 'days'

only datediff works just with actual dates, and I'd like to have the days number for every row counted automatically with the rsults in a new temporary column'days'; I hope it makes sense.
Please could you help or point me in right direction. Thank you

It looks like you've got it right except for the minus sign, (it should be a comma)...

DATEDIFF('date_finished', 'date_started') AS numberDays;

Hi is it possible to count days between columns, something like

datediff(date_finished-date_started) as 'days'

only datediff works just with actual dates, and I'd like to have the days number for every row counted automatically with the rsults in a new temporary column'days'; I hope it makes sense.
Please could you help or point me in right direction. Thank you

Thank you, it works, only now it returns values less 1 day, i.e. id start_date and finish_date are the same it returns '0'. Is it possible to change it?

I would say you could either put a DATE_ADD() around the dateFinished column....
DATEDIFF(DATE_ADD('date_finished', INTERVAL 1 DAY), 'date_started') AS numberDays;

a DATE_SUB() around the dateStarted column....
DATEDIFF('date_finished', DATE_SUB('date_started', INTERVAL -1 DAY)) AS numberDays;

or just add 1 to the result of your days like so...
DATEDIFF('date_finished', 'date_started') + 1 AS numberDays;

thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.