0

Oh StackOverflow! I do need thy help. I wish to execute something similar (and let's say identical for this purposes of this post) to this other question. Specific Time Range Query in SQL Server

Caveat, I want to do this on the client side....

Here's an example search criteria:

  • 3/1/2009 - 3/31/2009
  • between 6AM-10PM each day
  • Tues/Wed/Thurs only

Now this is all fine and dandy on the server side. Both SQL or Linq have functions like "DatePart" or Day of Week.

My initial reaction is to look for something hanging off of breeze.FilterQueryOp to construct a composite where clause which would accomplish the same, but I can't seem to figure out how to make the query only recognize date parts. DayOfWeek, TimePart, DayOfYear, and a few others have me completely baffled. Should anyone stumble upon this question, I humbly beg your assistance.

I could always use a SPROC, but then what's the point of using breeze anyways? ;)

Community
  • 1
  • 1
Oliver Kane
  • 888
  • 1
  • 6
  • 23
  • One thing that I have done recently similar to this querying the datetime property for your entity in the where statement, and then filtering out after doing your data call (ex. query.where([between your dates]) .executeQuery() and then doing a .filter where between your times before returning it to your view model. Like you mentioned, you may be able to do a predicate (two where clauses), but much like you without some trial and error I don't see an obvious way of doing this – PW Kad Jun 06 '13 at 14:51
  • I went away and felt compelled to come back. Just as a note, I have not tried exactly what you are mentioning, but I would consider looking at moment.js to help you with dates, times, and their various needs. I haven't tried moment.js in a Breeze query but I would be very surprised if it at least didn't make things easier, if not solve your issue above. – PW Kad Jun 06 '13 at 14:56
  • I actually use moment so frequently that I've overridden the default materialization to create moments and also serialize them back to the server. It's just an easier interface, and while it introduces higher coupling, Moment.js is always present in my web projects. Your suggestion is basically what I'm implmenting right now, as I can't think of a way to do this otherwise; however, it's very wasteful. I must throw away several times the results fetched by the db. :/ To make matters even more fun, the client cannot easily say "between x and y time on each day" because the db holds UTC times. – Oliver Kane Jun 06 '13 at 17:42
  • I hear you on storing them in UTC, I am trying to get over that hump right now. Good luck! – PW Kad Jun 06 '13 at 18:33

0 Answers0