-1

I need to get number of days between 2 dates, a given one and current date.

But in pure SQL, I mean without usign functions, it is possible?

For exaple

SELECT days (t.givenDate) - days (current date) FROM table t

Have you any idea?

Thaks a lot.

Csanchez
  • 373
  • 1
  • 16

1 Answers1

1

The built-in function is datediff(). The equivalent for the above is:

SELECT datediff(t.givenDate, curdate()) FROM table t;

Normally, givenDate would be in the past and you would want the arguments in the other order.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786