I know it is possible to extract a month from a datetime in sqlalchemy as an integer with:
func.extract('month', datetime)
but is it possible to change the days of the datetime to 1 in that month in a Postgres database in order to plot the data in a graph like with:
func.strftime(datetime, '%Y-%m')
which doesn't work for Postgres databases?
I have tried:
func.to_char
but I need to get the datetime or at least the date grouped by month or week in order to plot the data over time in graphs and this doesn't seem to get a datetime unless I am doing something wrong. Any ideas?
I know that it is changing a datetime to a string, but for some reason the func.strftime worked for plotting the graphs with SQLite but func.char doesn't for Postgres.
Would I have to just create 3 seperate columns for week, month and year and then combine them into a datetime in order to plot a graph of data that I need grouped by weeks or months?