Добрый день уважаемые форумчане! Возник такой достаточно интересный вопрос! В Террасофт 3.X при выборе на панели "Фильтры" фильтр по любой дате, например "Дате начала", "Дате завершения", и т.п...указав ему фильтр "Меньше или равно текущей даты" и нажать "Применить", программа выдаёт предупреждающее сообщение(которое прилагаю в аттаче). Сообщение несёт такую информацию - " Conversion failed when converting datetime from character string". Проделал трассировку что бы понять что именно происходит, получил вот такой код:
exec sp_executesql N'SELECT TOP 40
[tbl_Invoice].[ID] AS [ID],
[tbl_Invoice].[InvoiceDate] AS [InvoiceDate],
[tbl_Invoice].[InvoiceNumber] AS [InvoiceNumber],
[tbl_Invoice].[ContractID] AS [ContractID],
[tbl_Contract].[Title] AS [ContractTitle],
[tbl_Invoice].[PaymentDate] AS [PaymentDate],
[tbl_Invoice].[CustomerID] AS [CustomerID],
[Customer].[Name] AS [CustomerName],
[tbl_Invoice].[Amount] AS [Amount],
[tbl_Invoice].[BasicAmount] AS [BasicAmount],
[tbl_Invoice].[CampaignID] AS [CampaignID],
[tbl_Campaign].[Name] AS [CampaignName],
[tbl_Invoice].[OwnerID] AS [OwnerID],
[Owner].[Name] AS [OwnerName],
[tbl_Invoice].[BillStatusID] AS [BillStatusID],
[tbl_Invoice].[PaymentAmount] AS [PaymentAmount],
[tbl_Invoice].[ModifiedOn] AS [ModifiedOn],
[tbl_Invoice].[WorkflowItemID] AS [WorkflowItemID],
[Customer].[AccountTypeID] AS [CustomerAccountTypeID],
[tbl_Invoice].[BasicPaymentAmount] AS [BasicPaymentAmount],
[tbl_Invoice].[RestToPayAmount] AS [RestToPayAmount],
[tbl_Invoice].[BasicRestToPayAmount] AS [BasicRestToPayAmount],
[BillStatus].[IsFinish] AS [IsFinish]
FROM
[dbo].[tbl_Invoice] AS [tbl_Invoice]
LEFT OUTER JOIN
[dbo].[tbl_Contract] AS [tbl_Contract] ON [tbl_Contract].[ID] = [tbl_Invoice].[ContractID]
LEFT OUTER JOIN
[dbo].[tbl_Account] AS [Customer] ON [Customer].[ID] = [tbl_Invoice].[CustomerID]
LEFT OUTER JOIN
[dbo].[tbl_Campaign] AS [tbl_Campaign] ON [tbl_Campaign].[ID] = [tbl_Invoice].[CampaignID]
LEFT OUTER JOIN
[dbo].[tbl_Contact] AS [Owner] ON [Owner].[ID] = [tbl_Invoice].[OwnerID]
LEFT OUTER JOIN
[dbo].[tbl_BillStatus] AS [BillStatus] ON [BillStatus].[ID] = [tbl_Invoice].[BillStatusID]
WHERE((([tbl_Invoice].[InvoiceDate] >= @P1 AND
[tbl_Invoice].[InvoiceDate] @P2)) AND
([tbl_Invoice].[InvoiceDate] = (CAST(DATEPART(YEAR, getdate()) AS VARCHAR(4))) + ''.'' + (CASE WHEN (DATEPART(MONTH, getdate()) 10) THEN ''0'' ELSE '''' END + CAST(DATEPART(MONTH, getdate()) AS VARCHAR(2)))))
ORDER BY
3 DESC',N'@P1 datetime,@P2 datetime','2013-12-01 00:00:00','2014-01-01 00:00:00'
Очень смущает строка формирования года, месяца и даты(которая просто не генерируется). Т.е. по факту получаем формат ХХХХ.ХХ, что никак не совпадает с данными из SQL-таблиц. Гораздо проще написать ([tbl_Invoice].[InvoiceDate] = gatedate() Поэтому логичный вопрос, как это можно подправить, если я так понимаю данный код заложен в ядре программы?