First time Grafana user macro question

I have psql queries that grab data within date ranges. So if I have a query (in it’s simplest form):

select * from table_name where date >= ‘2018-1-1’ and date < ‘2018-1-31’

How can I use the date selector in my dashboard to substitute those dates with a macro variable? Not sure what I am missing because I thought that I could use __dateFrom() and __dateTo() ?? If so, what is the proper syntax?

Thanks in advance…

$__timeFrom() and $__timeTo()

They are all documented under http://docs.grafana.org/features/datasources/postgres/ or if you click the show help button below query editor.

Just to clarify my confusion, my Redshift table has a timestamp field (2018-1-1 00:00:00).

$__timeFrom() returns to_timestamp(1492750877) which generates an integer error because it is not a timestamp.

My actual query needs to generate a time series of pageviews with a selectable date range and I am unclear as how to accomplish this with Grafana macros so it sends a timestamp to Redshift without generating an err:

select count(action) as pageviews, date_part(‘day’, ts_action) as day
from insights.rawdata
where action=‘pageview’
and insights.rawdata.ts_action >= __timeFrom() and insights.rawdata.ts_action < __timeTo()
group by day ";
order by day ";

Oh I guess you need to use $__unixEpochFrom() on redshift cause it doesnt have to_timestamp(integer)