cancel
Showing results for 
Search instead for 
Did you mean: 

Assistance SP to restrict OQUT.DocDueDate based on specific Item

former_member459477
Participant
0 Kudos

Hello

I am trying to create a SP which restricts the 'Valid to' date of Quotes which contain a specific Item: (OQUT.DocDueDate)

--No valid to date later than 30 september for WGR -1-BSPP

If @object_type = '23' and @transaction_type IN ('A','U')

BEGIN

If Exists (Select T0.DocEntry from [dbo].[OQUT] T0 Inner Join QUT1 T1 On T0.DocEntry=T1.DocEntry

Where T0.DocEntry = @list_of_cols_val_tab_del and T1.ItemCode = 'WGR-1-BSPP' AND T0.DocDueDate > '30.09.2014')

BEGIN

Select @error = -1,

@error_message = 'Adjust valid to date, must be before 30th September'

End

End

The query is executing ok without error but I get following error when trying to add a quote with the part:

"The conversion of a varchar data type to a datetime data type resulted in an out-of-range value (CINF.)"

I can see that my understanding of the dating part is wrong - can anyone assist?

Thanks

Karen

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Try this:

--No valid to date later than 30 september for WGR -1-BSPP

If @object_type = '23' and @transaction_type IN ('A','U')

BEGIN

If Exists (Select T0.DocEntry from [dbo].[OQUT] T0 Inner Join QUT1 T1 On T0.DocEntry=T1.DocEntry

Where T0.DocEntry = @list_of_cols_val_tab_del and T1.ItemCode = 'WGR-1-BSPP' AND T0.DocDueDate > convert(datetime,'20140930',103))

BEGIN

Select @error = -1,

@error_message = 'Adjust valid to date, must be before 30th September'

End

End

Regards,

JC.

former_member459477
Participant
0 Kudos

Thank you very much for assistance.

Regards,

Karen

Answers (0)