Forum Discussion

softech's avatar
softech
Guide
5 months ago

any easy way to find post for today and yesterday...

Hi, i am tyring ton find out total new thread for today or yesterday using

https://mycommunity/api/2.0/search?q=SELECT count(*) FROM%20messages%20where post_time>=2024-05-01T00:00:00.000-00:00 and post_time <= 2024-05-01T23:59:59.999-00:00 and depth = 0

 

is there any way to filter out post_time using by calling something like getdate() or for yesterday like getdate()-1?

 

thanks

  • softech it is possible by using the custom FreeMarker context object datesupport that Khoros provides, that will allow you to do something like this:

    ${datesupport.now.addDay(-1).date?datetime?iso_utc}
    
    <#assign 24hoursago = datesupport.now.addDay(-1).date?datetime?iso_utc />
    <#assign query = "SELECT * FROM messages WHERE post_date > ${24hoursago}" />