Dear Experts ,
am Making a query ro calculate the difference in months between two UDF
based on the result of this query it will select a specific number , that i will put it into a third UDF ,
the query is working fine , but not when i use $[fieldname] ,
it will be used inside marketing document before adding the document the user will select two dates and based on the number of months in different , a number will be the result ,
now here is the query as it work dine without the $[] , but it need to 1st add the document then to use it cuz am using where docnum=$[] .
select(case when DATEDIFF(MONTH, oqut.U_StartDate , oqut.U_EndtDate ) BETWEEN 1 AND 3 then (Select 1)
else(case when DATEDIFF(MONTH, oqut.U_StartDate , oqut.U_EndtDate ) BETWEEN 4 AND 6 then (Select 2) end) end)
from oqut
WHERE oqut.DOCNUM= $[oqut.DOCNUM]
and this is the same query when am using $[] , but in this case it won't work:
select(case when DATEDIFF(MONTH, $[oqut.U_StartDate] , $[oqut.U_EndtDate] ) BETWEEN 1 AND 3 then (Select 1)
else(case when DATEDIFF(MONTH, $[oqut.U_StartDate] , $[oqut.U_EndtDate] ) BETWEEN 4 AND 6 then (Select 2) end) end)
from oqut