The list below illustrates how to convert the most popular MySQL built-in functions into SQL Server equivalents:
CURRENT_TIMESTAMP
and now()
into getdate()
isnull(expression)
by expression is null
from_unixtime(expression)
by
DateAdd(ss, expression, '01-01-1970')
CURRENT_DATE
and curdate()
by CAST(getdate() as date)
CURRENT_TIME
and curtime()
into CAST(getdate() as time)
timediff($date1, $date2)
by CAST($date2 - $date1 AS TIME)
RAND()
by newID()
DAY($date)
or DAYOFMONTH($date)
by DATENAME(d, $date)
DAYOFYEAR($date)
by DATENAME(dy, $date)
DAYNAME($date)
by DATENAME(dw, $date)
HOUR($date)
by DATENAME(hh, $date)
Have questions? Contact us