2

SQL Server allows getting a current date with this query:

select getdate()

In 1C query, it doesn't work. I need to get the current date in the DataCompositionScheme query and I don't know how to do it. Function CurrentDate() doesn't work in queries, only in scripts.

I know that in queries I can use parameters, for example:

Query.Text = "select &getdateparameter";
Query.SetParameter("getdateparameter",CurrentDate())

but is it possible to do the same in the DataCompositionScheme query?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Eugene
  • 105
  • 5

1 Answers1

2

You can use parameters in data composition schema too. If you specify it in query that you use as data source in data composition schema, they will appear on the Parameters tab. There also will be built-in parameters used to filter data in periodic registers.

Img.1

On the Parameters tab, you can set value (the Value column) if this parameter is static, but usually, you would like parameters to be changeable by user. In this case, you need to clear checkboxes in the Availability restriction column. Also, on the Parameters tab you can use global context function CurrentDate() (the Expression column)

Img.2

Then you can specify default values for parameters, for example, beginning of this week or beginning of this day in your case on the Parameters tab of the Settings tab.

Img.3

JuLe
  • 115
  • 6
  • 1
    Thank you, @Jule. Only perhaps better I will use `CurrentSessionDate()` instead of `CurrentDate()` to avoid any issue with time zones. – Eugene Dec 22 '21 at 09:43