The function dateTime is there to create a date and time literal and can indeed only be used with literal integers as parameters. For example, dateTime(2010,4,9,10,2,0) for the time that I started writing this reply.
What you want to do can be achieved by constructing a textual date and then parsing it as follows:
parseDateTime($year + '-' + $month + '-' + $day, 'yyyy-MM-dd')
Dear Mendix,
Is the dateTime function obsolete, in this way? When it does not accept the integer/Long type of Mendix, it is only usable with a hard coded value. That is not recommend to do in any case.
Would be nice it this 'bug' is documented in the official documentation including the workaround. https://world.mendix.com/display/refguide5/Date+creation (That would save many programmers an annoying 20 minutes, to discover that the function is useless)
Or even better; change the input type of the function, so it will accept a data type that is used by the Mendix platform!
Cheers, Andries