Getting the Year and Month from an int date for a partition
I have a field defined as int that stores a date value ... 20150101 (for January 1, 2015) for example. The table has no datetime field.
I would like to partition the table based on YYYYMM (201501, 201502, etc)
Suggestions on how to do that beyond adding a new column?
Thanks
I would like to partition the table based on YYYYMM (201501, 201502, etc)
Suggestions on how to do that beyond adding a new column?
Thanks
0
Comments
PARTITION BY left(cast (ColumnName as char(8)),6)
But... why do we forget math so easily? Now compare to your solution: {CAST AS CHAR}, {LEFT}
Regards.