In our support life we all are working of multiple RDBMS at same. It's tough to remember all function available in different RDBMS. We try to run same query which was running in another RDBMS :). Here i am comparing the date function available in MS SQL Server and MySQL. Hope this will help.
SQL
SERVER
|
MYSQL
|
DATEADD(day,
1, GETDATE())
|
DATE_ADD(NOW(),
INTERVAL 1 DAY)
|
DATEDIFF(day,
GETDATE(),
GETDATE()-1) |
DATEDIFF(NOW(),
NOW() – INTERVAL 1 DAY)
|
DATENAME(month,
GETDATE())
|
DATE_FORMAT(NOW(),
‘%M’)
MONTHNAME(NOW()) |
DATENAME(weekday,
GETDATE())
|
DATE_FORMAT(NOW(),
‘%W’)
DAYNAME(NOW()) |
DATEPART(month,
GETDATE())
|
DATE_FORMAT(NOW(),
‘%m’)
|
DAY(GETDATE())
|
DATE_FORMAT(NOW(),
‘%d’)
DAY(NOW())) DAYOFMONTH(NOW()) |
GETDATE()
|
NOW()
SYSDATE() CURRENT_TIMESTAMP CURRENT_TIMESTAMP() |
GETDATE()
+ 1
|
NOW() +
INTERVAL 1 DAY
CURRENT_TIMESTAMP + INTERVAL 1 DAY |
GETUTCDATE()
|
UTC_TIMESTAMP()
|
MONTH(GETDATE())
|
MONTH(NOW())
|
YEAR(GETDATE())
|
YEAR(NOW())
|
No comments:
Post a Comment