bs-sql-composer
bs-sql-composer copied to clipboard
Modeling `SELECT 'The time is ' || time('now');`
Example https://repl.it/@idkjs/KnownLinearBase
How would you model the following with this library?
SELECT 'The time is ' || time('now');
SELECT 'Tomorrow will be ' || date('now', '+1 day');
SELECT 'Today is day ' ||
(cast(
julianday('now')
- julianday('now', 'start of year')
as int) + 1)
|| ' of ' || strftime('%Y', date('now'));
Or maybe its not expected to. Thanks.
My apologies for missing this. Currently that syntax is not supported. Is this a SQLite specific syntax or is it standard ANSI/ISO SQL? On MySQL v8 I'm receiving syntax errors when attempting to run statements 2 & 3.
Statement 1
SELECT 'The time is ' || time('now');
Responds with:
+-------------------------------+
| 'The time is ' || time('now') |
+-------------------------------+
| NULL |
+-------------------------------+
1 row in set, 3 warnings (0.00 sec)
Statement 2
SELECT 'Tomorrow will be ' || date('now', '+1 day');
Responds with:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', '+1 day')' at line 1
Statement 3
SELECT 'Today is day ' ||
(cast(
julianday('now')
- julianday('now', 'start of year')
as int) + 1)
|| ' of ' || strftime('%Y', date('now'));
Responds with:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'int) + 1)
|| ' of ' || strftime('%Y', date('now'))' at line 5