1
I own a field of the kind datetime
and I need to make a consultation based only on the month and year. While researching, I noticed that there is the function extract
, but it separates only one value from the datetime
.
example:
SELECT * FROM mytable
WHERE EXTRACT(month from date_column) = 5
AND EXTRACT(year from date_column) = 2018;
Is there any function that does this "Extract" instead of using the AND
?
to do exactly what EXTRACT does in its simplicity I do not know, but I also see no reason to have. you could use a sub string and compare a part of the date plus it arrive and be a gabiarra comparing what EXTRACT does.
– Marco Souza
You can use the date_trunc('Month', seu_campo_timestamp function).
– anonimo