How to create a filter to get data by day and month?

Certified Associate Developer

Hello. I currently have a database table with thousands of news from different dates. I would like to create a query that brings me the news by days and by month, but not by year. For example, the news of July 4 from different years. Thank you for your help.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    You could create a view in the DB to separate the three values from the date into three fields and then query each individually. With Appian synced records, this should also work pretty easily.

  • Agree with Stefan, in MSSQL for example we can create a view that utilizes DATEPART() over a datetime field to break out day, month and year integers to be used in report filtering.

    Just note that this does bypass Appian's auto conversion of datetime values stored as GMT in your database, so the day, month, year will be GMT and not local time, unless you add a mechanism to the DB such as a function to convert to a specific timezone.  Likely not that big of a deal for this use case.

  • You can create a query to bring news by day and by month, but not by year, by using the "GROUP BY" clause in SQL. Here's an example using MySQL:

    SELECT 
        DAY(date_column) AS day, 
        MONTH(date_column) AS month, 
        COUNT(*) AS total 
    FROM 
        your_table 
    GROUP BY 
        DAY(date_column), 
        MONTH(date_column) 
    ORDER BY 
        month, day
    

    In this example, date_column is the name of the column in your database table that stores the dates of the news. The query first extracts the day and month from each date in the date_column using the DAY and MONTH functions, respectively geometry dash lite. The GROUP BY clause then groups the data by the extracted day and month, and the COUNT function counts the number of news for each group. The query results will be ordered by the month and day.

  • Although others gave suggestions for doing this in the database, I would suggest using syced records and custom record fields to achieve this instead. If you enable data sync, you could create a custom field that returns the month and day, something like this: 

    datetext(ri!date, "MMMM d")

    Then, you can use that in queries. For instance, you could aggregate on that custom field to find the count of news by each day + month.