Skip to Content
0
Jun 08 at 04:03 PM

How to query dates using "between" parameter ?

62 Views Last edit Jun 08 at 04:07 PM 3 rev

Hello Experts,

I need to set validation for the below condition.

Condition : If user try to enter a From Date/ To Date between the existing From date and To date, it should through error.

Here in the example image the second record is invalid as its From Date falls between First Row's From and To.

I tried the below code:

	var queryPP = CBO_PayPeriod.QueryByElements;
	var queryPP_SelParams = queryPP.CreateSelectionParams();

	queryPP_SelParams.Add(queryPP.FromDate, "I", "BT", this.FromDate, this.ToDate );//, this.ToDate);
	queryPP_SelParams.Add(queryPP.ToDate, "I", "BT", this.FromDate, this.ToDate );//, this.ToDate);

	var queryPP_Results = queryPP.ExecuteFromDBDataOnly(queryPP_SelParams);


	if (queryPP_Results.Count() > 1)
	{
		raise Msg.Create("E", "Payperiod already available for the selected from and to date");
		return false;
	}

But my query doesn't return any record, so the validation fails. Could anyone point what could be issue ?

Thanks,

Senz

Attachments

ytvrn.png (38.6 kB)
njaxl.png (17.9 kB)