Skip to Content
-1

Filtering query result based on DATE functions

Apr 25, 2017 at 12:49 AM

45

avatar image

I'm having some difficulty filtering table data based on the month and year of a timestamp column in the table. I know I can do:

SELECT MONTH(CURRENT_UTCTIMESTAMP) AS MY_MONTH FROM MY_TABLE

which returns a column called MY_MONTH with numeric data of the month ordinals but I need to be able to do something like:

SELECT MONTH(CURRENT_UTCTIMESTAMP) AS MY_MONTH FROM MY_TABLE WHERE MY_MONTH=4

...and I can't seem to be able to do this. I'm guessing it's something very simple I'm missing.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Steve Lamb
Apr 25, 2017 at 12:59 AM
1

Just figured it out:

SELECT * FROM MY_TABLE WHERE MONTH(CURRENT_UTCTIMESTAMP) = 4

Share
10 |10000 characters needed characters left characters exceeded