Databases: date and time functions
Unfortunately databases don’t all use the same SQL language. In most cases, the notation of SQL queries is roughly the same, however in some cases there are differences, for instance when working with dates and times:
- SQL Server: getdate()
- Oracle: sysdate
- Solid: now()
- mySQL: now()
- Access: now
Calculation with dates on various databases also differs. SQL Server has the DateAdd funtion, Oracle has overloaded operators so you can use + to increase dates by default with a number of days. Solid has a particular notation: SELECT {fn timestampadd(SQL_TSI_DAY, 30, now())}, which gets us the current date + 30 days. mySQL uses a similar notation but doesn’t require the {fn} syntax:
SELECT TIMESTAMPADD(DAY, 30, now()).