The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Active user
Rating: 3
Joined: Apr 2, 2025
Company:

Why following query gives "Wrong parameter" error?


Code
SELECT
   DATETIME(YEAR(&Period), MONTH(&Period), 7) AS MyCustomDate
INTO DatesRawData

Edited: Bahrom - Dec 10, 2025 04:54 PM
 
#2
People who like this: 0 Yes / 0 No
Administrator
Rating: 30
Joined: Oct 3, 2019
Company:

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

 
#3
People who like this: 0 Yes / 0 No
Active user
Rating: 3
Joined: Apr 2, 2025
Company:

Well, I wanted to generate all days of a given date, "&Period".

If "&Period" is 2025-12-17 then I must generate

2025-12-1
2025-12-2
2025-12-3
...
2025-12-31

I did following query

[CODE][/CODE]

(I can't continue editing this post of mine. I am frequently getting "Access denied" error at this site)

Edited: Bahrom - Apr 10, 2026 07:35 PM
 
#4
People who like this: 0 Yes / 0 No
Administrator
Rating: 30
Joined: Oct 3, 2019
Company:

Hello Bahrom,

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 :-)

 
#5
People who like this: 0 Yes / 0 No
Active user
Rating: 3
Joined: Apr 2, 2025
Company:

Bro, It is for a real very very serious work project.

Edited: Bahrom - Apr 10, 2026 07:37 PM
 
#6
People who like this: 0 Yes / 0 No
Administrator
Rating: 30
Joined: Oct 3, 2019
Company:

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

 
Subscribe
Users browsing this topic (guests: 3, registered: 0, hidden: 0)