I am trying to find the earliest and latest timestamp of a text message. I know I have to change the following column to date format to be able to order by:
Fri May 26 17:30:01 +0000 2017
Fri May 26 17:30:05 +0000 2017
Fri May 26 17:30:05 +0000 2017
Fri May 26 17:30:04 +0000 2017
Fri May 26 17:30:12 +0000 2017
I have tried using the 'substr' function to convert into YYYY-MM-DD HH:MM:SS
This is what I have for now:
dbGetQuery(db2, "SELECT text,
CAST(
SUBSTR(created_at,-4) || '-' ||
CASE SUBSTR(created_at,5,3)
WHEN 'Jan' THEN 01
WHEN 'Feb' THEN 02
WHEN 'Mar' THEN 03
WHEN 'Apr' THEN 04
WHEN 'May' THEN 05
WHEN 'Jun' THEN 06
WHEN 'Jul' THEN 07
WHEN 'Aug' THEN 08
WHEN 'Sep' THEN 09
WHEN 'Oct' THEN 10
WHEN 'Nov' THEN 11
WHEN 'Dec' THEN 12
END || '-' ||
SUBSTR(created_at, 9,2)
AS date)
FROM tweets")
I only get the YYYY. Any help will be much appreciated. Thank you.