This construct will not work! The 1C query language is not a full SQL language, and of course it has its limitations… For example, the DATETIME function only works when numeric parameters are passed to it. And although the result of the YEAR function is also of type Number, DATETIME still does not accept it…
In your case, you can do it differently:
Code
SELECT
DATEADD(BEGINOFPERIOD(&Period, MONTH), DAY, 7) AS FIELD
could you please clarify: is this for a learning exercise or for a real work project?
The reason I ask is that due to the limitations of the query language in 1C, it's sometimes easier to perform certain operations directly in 1C code rather than within a query.
I'll try to help you either way, but please keep this in mind
If we need to generate all the days of a month using only a query, we can do it like this:
1. Create a set of numbers from 0 to 30 2. Add them to the first day of the month 3. Trim off dates that fall outside the month
The query text will look something like this:
Code
SELECT
DATEADD(BEGINOFPERIOD(&Period, MONTH), DAY, Numbers.DayOffset) AS DayDate
FROM
(SELECT 0 AS DayOffset
UNION ALL SELECT 1
UNION ALL SELECT 2
UNION ALL SELECT 3
UNION ALL SELECT 4
UNION ALL SELECT 5
UNION ALL SELECT 6
UNION ALL SELECT 7
UNION ALL SELECT 8
UNION ALL SELECT 9
UNION ALL SELECT 10
UNION ALL SELECT 11
UNION ALL SELECT 12
UNION ALL SELECT 13
UNION ALL SELECT 14
UNION ALL SELECT 15
UNION ALL SELECT 16
UNION ALL SELECT 17
UNION ALL SELECT 18
UNION ALL SELECT 19
UNION ALL SELECT 20
UNION ALL SELECT 21
UNION ALL SELECT 22
UNION ALL SELECT 23
UNION ALL SELECT 24
UNION ALL SELECT 25
UNION ALL SELECT 26
UNION ALL SELECT 27
UNION ALL SELECT 28
UNION ALL SELECT 29
UNION ALL SELECT 30) AS Numbers
WHERE
DATEADD(BEGINOFPERIOD(&Period, MONTH), DAY, Numbers.DayOffset) <= ENDOFPERIOD(&Period, MONTH)
ORDER BY
DayDate