MySQL compared to MS SQL Server

GETDATE

curdate() returns date only

now() is equivalent to sql server getdate() -- it returns datetime

SELECT *

FROM mytable

WHERE create_date BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE

or

SELECT *

FROM mytable

WHERE create_date BETWEEN NOW() - INTERVAL 30 DAY AND NOW()

or

select * from Stocks where date(lastmodifieddate)=date(curdate())

________________________________________

DATEDIFF() function:

In mysql, it is just Datediff(date1,date2) and it always returns days.

Use TIMESTAMPDIFF if you want to compare dates with other units of measure.

Timestampdiff(minute, date1, date2)

The unit argument can be: MICROSECOND (microseconds), SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, or YEAR.

________________________________________

TOP FUNCTION:

SQL Server:

Select top 1 from table order by date

MySQL:

Select * from table order by date limit 1;