Forum Discussion

PerBonomi's avatar
9 years ago

Get messages from certain date range

 

Hi there.

 

I'm getting start and end dates dynamically from the current url (so admins can choose their own dates):

?startDate=2016-01-01&endDate=2016-02-15

<#assign dateStart = http.request.parameters.name.get("startDate", "")?string />
<#assign dateEnd = http.request.parameters.name.get("endDate", "")?string />

Now I'm trying to use these dates to get messages within that range, but I can't seem to get it to work.

 

SELECT count(*) FROM messages WHERE author.id = '${user.id}' AND post_time > '${dateStart}' AND post_time < '${dateEnd}'

I've been reading about different (iso) formats, converting with certain ?string variables, but I just seem to be stuck. Freemarker and dates are my biggest weakness.

 

Help?

    • PerBonomi's avatar
      PerBonomi
      Boss

      Hmm, not really, but thanks. I'm fine using milliseconds, but I can't get the date string, ex. 2016-01-01, converted to milliseconds.

      • PerBonomi's avatar
        PerBonomi
        Boss

        Never mind, found the problem. I was converting the date into a string by using '${dateStart}' instead of just ${dateStart} in the query.

        Major brainfart :)