Hello,
NOTE: I have not looked at the code for the sql statements yet, nor do I know how the persian calender works.
I reckon one of the more easier solutions that you could implement would be to have 2 fields int the table structure, one to represent the first field of your date and the other for the second field. Then you could do something like this:
DECLARE
@SeparatorPos int,
@FromDateField1 int,
@FromDateField2 int,
@ToDateField1 int,
@ToDateField2 int ;
SET @SeparatorPos = SELECT CHARINDEX('/', @FromDate);
SET @FromDateField1 = CAST(SUBSTRING(@FromDate, 1, (@SeparatorPos - 1)) AS int);
SET @FromDateField2 = CAST(SUBSTRING(@FromDate, (@SeparatorPos + 1), LEN(@FromDate)) AS int);
SET @SeparatorPos = SELECT CHARINDEX('/', @ToDate);
SET @ToDateField1 = CAST(SUBSTRING(@ToDate, 1, (@SeparatorPos - 1)) AS int);
SET @ToDateField2 = CAST(SUBSTRING(@ToDate, (@SeparatorPos + 1), LEN(@ToDate)) AS int);
WHERE
(
([TableDateFirstField] BETWEEN @FromDateField1 AND @ToDateField1)
AND
([TableDateSecondField] BETWEEN @FromDateField2 AND @ToDateField2)
)
Hope this helps :)...
DISCLAIMER: This is by no means the 'most correct' way of doing this. I take no responsiblity if this code, for some or other reason, causes the lifecycle of the common sea cucumber to become irrevocably broken... ;P