0

So I want to convert this redshift query to MySQL. This is about getting the date truncating it then converting it to string

I tried doing this

SELECT DATE_FORMAT(CONVERT_TZ('material_boxes.created','UTC','America/New_York'),'%m') AS "month_only" FROM material_boxes

The redshift query is this

SELECT TO_CHAR(DATE_TRUNC('month', CONVERT_TIMEZONE('UTC', 'America/New_York', material_boxes.created )), 'YYYY-MM') AS "month_only" FROM material_boxes

The result should be the month only.

IMParasharG
  • 1,869
  • 1
  • 15
  • 26

1 Answers1

0

I did it by removing '' in material_boxes.created and changing "%m" to "%M" for the string for month.

SELECT DATE_FORMAT(CONVERT_TZ('material_boxes.created','UTC','America/New_York'),'%m') AS "month_only" FROM material_boxes