Q:

MapServer cgi-bin get value from query string and concatenate to Postgres query

I'm working with cgi-bin and I show a map with some data from a Postgres database.
But, I need to introduce an input where the user could select a date and this date would filter the results from the database.
I have the input and I send the parameter by the URL (get method), but I don't know how to get this parameter from the cgi-bin query string and how to concatenate the parameter's value to the database query.
This is the mapfile's code portion: 
LAYER
DATA "the_geom from (select * from
  vista_puntos where date > <DATE_VAR_FROM_QUERY_STRING>) as subquery
  using unique id_valor using srid=4326"

A:

use select query in DATA
after that use FILTER
*MAPSERV* create a Where clause for Filter
example
    DATA "geom from roads"
    FILTER "type='%road1%' or type='%road2%'"

        CLASS
            NAME "Road Type1"
            EXPRESSION ('[type]' = 'type1')
            STYLE
                SIZE 10
                COLOR 255 0 0 
            END
        END

        CLASS
            NAME "Road Type2"
            EXPRESSION ('[type]' = 'type2')
            STYLE
                SIZE 10
                COLOR 0 255 0
            END
        END

Query String format is like : ..mapserv.exe?map=mapfile&road1=type1&road2=type2

