DateDiff in sql

There is a function in sql called DateDiff that shows you the days elapsed from the current date to one passed by parameter.

DateDiff(“y”,$date,now())

An example would be the following:
select * from invoices where DateDiff(“y”,$date,now())
This sentence would return the invoices made in a period of 30 days from the current date.

I hope it helps you, anyway you can see more sql functions in an article that we have in Desarrolloweb called where there are also other functions for dates that can come in handy.

See also  All about WordPress
Loading Facebook Comments ...
Loading Disqus Comments ...