cancel
Showing results for 
Search instead for 
Did you mean: 

Filter by date and time

resmi_v
Participant
0 Kudos

Dear Experts,

I want to concatenate date and time fields and do a query operation.

Currently , i have fromdate and todate (both date type) ;I use the below code to query

var result== Results.Where(dtRule => today.IsBetween(dtRule.FromDate, dtRule.ToDate)|| (dtRule.FromDate.ToString() == "" && dtRule.ToDate.ToString() == ""))

This is working fine to filter by dates.

But now business needs to add new filter by date also.So I have added 2 new fields fromtime and totime (both time datatypes).

Now how can i filter the results between fromdate+fromtime and todate+totime.

Thanks in advance.

Thanks,

Resmi

Accepted Solutions (0)

Answers (1)

Answers (1)

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Resmi,

Do you have Date and Time fields in your collection or also a DateTime field too?

Bye,
. Horst

resmi_v
Participant
0 Kudos

I have date and time fields and no datetime fields

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Resmi,

Then you need to do it manually with a logical conjunction of

  • FromTime.LessThan( <your current time> )
    and
  • ToTime.GreaterThan( <you current time> )

HTH,
. Horst