Clear sky!

1s enterprise 8.2 (8.2.15.289)

In the tabular part of the document there is a field with a composite data type. One type is string. The string always has a similar view "10.10.2012 - 10.10.2013", and the dates may be different.

I need to somehow get the second date out of the line (in this case, "10.10.2013") and compare it with the date type parameter.

How can I do that?

    4 answers 4

    I'll start from afar - today I started to hate 1C even more.

    And now in the case.

    Two days of surfing to find the answer to the question. The result was such an uncomplicated query design:

    ДОБАВИТЬКДАТЕ(ДОБАВИТЬКДАТЕ(ДОБАВИТЬКДАТЕ(&НачалоМ, Год, ВЫБОР Когда подстрока(выразить(ТабличнаяЧасть.НомерВыхода как строка(23)), 22, 2) = "13" ТОГДА 2012 КОНЕЦ), месяц, ВЫБОР Когда подстрока(выразить(ТабличнаяЧасть.НомерВыхода как строка(23)), 17, 2) = "05" ТОГДА 4 КОНЕЦ), день, ВЫБОР Когда подстрока(выразить(ТабличнаяЧасть.НомерВыхода как строка(23)), 14, 2) = "29" ТОГДА 28 ИНАЧЕ ВЫБОР Когда подстрока(выразить(ТабличнаяЧасть.НомерВыхода как строка(23)), 14, 2) = "30" ТОГДА 29 ИНАЧЕ ВЫБОР Когда подстрока(выразить(ТабличнаяЧасть.НомерВыхода как строка(23)), 14, 2) = "31" ТОГДА 30 КОНЕЦ КОНЕЦ КОНЕЦ 

    Please note that this request takes into account only one year, only one month, and the last three days. So you need to add over9000 lines of code here so that you can view at least a few more years (with a margin), all 12 months and 31 days ...


    And all because the DATE function does not understand other functions in the arguments, and if they did, then the query cannot represent the string as a date, except as the above-mentioned onanism .


    you can not just take and write a normal query

    • Well, this is not the case, of course. We must go the right way. Add two requisites, transfer the data there, transfer them to the date. In general, the data structure is flawed. - Yura Ivanov
    • The structure in some places is terrible. I sometimes just cry. I would cut off the hands of the one who did all this. - teanYCH
    • And why not turn out to allocate a substring: 10/10/2013 to remake it into a string: 20131010 and then: DATE ("20131010") to compare with anything of the type "date"? - ReinRaus
    • because it is impossible to give data types in 1C queries, and two different types cannot be compared. Therefore it is necessary to collect the date piece by piece - teanYCH

    See the functions ПОДСТРОКА and ДАТАВРЕМЯ

    • Invalid parameters "DATE" (DateTime (<<? >> Substring (express (TabularPart.Number of Output as a string (23)), 20, 23) - teanCH
    • first a substring of 12 characters from the end, and then a date. - uilenspiegel
    • @uilenspiegel, 1. The DATE function takes arguments in the following format: DATE (yyyy, mm, dd, hh, mm, ss), so you can’t just put the existing string there. 2. why 12 characters? at the date of 10. I do not need a dash and a space before the date. 3. DATE I swear on my substrings in any form. - teanYCH

    Try to do the opposite. Bring the date type parameter to the “line” or transfer this parameter as a line immediately, cut the second date from the table part and compare

      Although a lot of time has passed, it may be useful to someone who accidentally glances into this topic (he himself once suffered on a similar problem):

       ВЫБРАТЬ 0 КАК Цифра, "0" КАК Буква ПОМЕСТИТЬ ЦифраБуква ОБЪЕДИНИТЬ ВЫБРАТЬ 1, "1" ОБЪЕДИНИТЬ ВЫБРАТЬ 2, "2" ОБЪЕДИНИТЬ ВЫБРАТЬ 3, "3" ОБЪЕДИНИТЬ ВЫБРАТЬ 4, "4" ОБЪЕДИНИТЬ ВЫБРАТЬ 5, "5" ОБЪЕДИНИТЬ ВЫБРАТЬ 6, "6" ОБЪЕДИНИТЬ ВЫБРАТЬ 7, "7" ОБЪЕДИНИТЬ ВЫБРАТЬ 8, "8" ОБЪЕДИНИТЬ ВЫБРАТЬ 9, "9" ; 

      ////////////////////////////////////////////////// //////////////////////////////

       ВЫБРАТЬ ЦифраБуква.Цифра ПОМЕСТИТЬ День1 ИЗ ЦифраБуква КАК ЦифраБуква ГДЕ ЦифраБуква.Буква = ПОДСТРОКА(&СтрокаДат, &НачальныйСимвол, 1) ; 

      ////////////////////////////////////////////////// //////////////////////////////

       ВЫБРАТЬ ЦифраБуква.Цифра ПОМЕСТИТЬ День2 ИЗ ЦифраБуква КАК ЦифраБуква ГДЕ ЦифраБуква.Буква = ПОДСТРОКА(&СтрокаДат, &НачальныйСимвол + 1, 1) ; 

      ////////////////////////////////////////////////// //////////////////////////////

       ВЫБРАТЬ ЦифраБуква.Цифра ПОМЕСТИТЬ Месяц1 ИЗ ЦифраБуква КАК ЦифраБуква ГДЕ ЦифраБуква.Буква = ПОДСТРОКА(&СтрокаДат, &НачальныйСимвол + 3, 1) ; 

      ////////////////////////////////////////////////// //////////////////////////////

       ВЫБРАТЬ ЦифраБуква.Цифра ПОМЕСТИТЬ Месяц2 ИЗ ЦифраБуква КАК ЦифраБуква ГДЕ ЦифраБуква.Буква = ПОДСТРОКА(&СтрокаДат, &НачальныйСимвол + 4, 1) ; 

      ////////////////////////////////////////////////// //////////////////////////////

       ВЫБРАТЬ ЦифраБуква.Цифра ПОМЕСТИТЬ Год1 ИЗ ЦифраБуква КАК ЦифраБуква ГДЕ ЦифраБуква.Буква = ПОДСТРОКА(&СтрокаДат, &НачальныйСимвол + 6, 1) ; 

      ////////////////////////////////////////////////// //////////////////////////////

       ВЫБРАТЬ ЦифраБуква.Цифра ПОМЕСТИТЬ Год2 ИЗ ЦифраБуква КАК ЦифраБуква ГДЕ ЦифраБуква.Буква = ПОДСТРОКА(&СтрокаДат, &НачальныйСимвол + 7, 1) ; 

      ////////////////////////////////////////////////// //////////////////////////////

       ВЫБРАТЬ ЦифраБуква.Цифра ПОМЕСТИТЬ Год3 ИЗ ЦифраБуква КАК ЦифраБуква ГДЕ ЦифраБуква.Буква = ПОДСТРОКА(&СтрокаДат, &НачальныйСимвол + 8, 1) ; 

      ////////////////////////////////////////////////// //////////////////////////////

       ВЫБРАТЬ ЦифраБуква.Цифра ПОМЕСТИТЬ Год4 ИЗ ЦифраБуква КАК ЦифраБуква ГДЕ ЦифраБуква.Буква = ПОДСТРОКА(&СтрокаДат, &НачальныйСимвол + 9, 1) ; 

      ////////////////////////////////////////////////// //////////////////////////////

       ВЫБРАТЬ ДОБАВИТЬКДАТЕ(ДОБАВИТЬКДАТЕ(ДОБАВИТЬКДАТЕ(ДАТАВРЕМЯ(1, 1, 1, 0, 0, 0), ДЕНЬ, 10 * День1.Цифра + День2.Цифра - 1), МЕСЯЦ, 10 * Месяц1.Цифра + Месяц2.Цифра - 1), ГОД, 1000 * Год1.Цифра + 100 * Год2.Цифра + 10 * Год3.Цифра + Год4.Цифра - 1) КАК КонечнаяДата ИЗ День1 КАК День1 ЛЕВОЕ СОЕДИНЕНИЕ День2 КАК День2 ПО (ИСТИНА) ЛЕВОЕ СОЕДИНЕНИЕ Месяц1 КАК Месяц1 ПО (ИСТИНА) ЛЕВОЕ СОЕДИНЕНИЕ Месяц2 КАК Месяц2 ПО (ИСТИНА) ЛЕВОЕ СОЕДИНЕНИЕ Год1 КАК Год1 ПО (ИСТИНА) ЛЕВОЕ СОЕДИНЕНИЕ Год2 КАК Год2 ПО (ИСТИНА) ЛЕВОЕ СОЕДИНЕНИЕ Год3 КАК Год3 ПО (ИСТИНА) ЛЕВОЕ СОЕДИНЕНИЕ Год4 КАК Год4 ПО (ИСТИНА) 

      Options:

      • СтрокаДат - as in the first message,
      • НачальныйСимвол = 14 in this case.
      • Some kind of hell. Also badly formatted. - Roman