Something like this for QTD:
(ApplySimple("to_char((#0),'YYYYQ')", ?DT) = ApplySimple("to_char((#0),'YYYYQ')", [date attribute]@ID)) AND (ApplySimple("#0", [date attribute]@ID) <= ApplySimple("#0", ?DT))
And for MTD:
(ApplySimple("to_char((#0),'YYYYMM')", ?DT) = ApplySimple("to_char((#0),'YYYYMM')", [date attribute]@ID)) AND (ApplySimple("#0", [date attribute]@ID) <= ApplySimple("#0", ?DT))
Hope that these help,
dinzana