Skip to Content
0

Filter by date and time

Mar 27, 2017 at 09:19 AM

92

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Horst Schaude
Mar 27, 2017 at 11:14 AM
0

Hello Resmi,

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

Bye,
. Horst

Show 2 Share
10 |10000 characters needed characters left characters exceeded

I have date and time fields and no datetime fields

0

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

0