0

Whilst using DB Browser for SQLite, how can I convert e.g.:

2017-06-20T23:12:58Z

to just the date (2017-06-20) without the characters "T" and "Z" and without the time?

If I use CAST(expression as date) or CAST(expression as datetime) I get the year (2017) only and not the date and month.

bz_2020
  • 79
  • 1
  • 14

1 Answers1

0

SQLite doesn't have a date type. But you can do some simple string parsing.

Try this:

SELECT d.orig_date, substr(d.orig_date, 1, INSTR(d.orig_date,'T') -1 ) as new_date_only
FROM 
    (SELECT '2017-06-20T23:12:58Z' as orig_date
    ) d
sql_shark
  • 36
  • 2