Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Linq where dates question

Linq where dates question

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqhelpquestion
5 Posts 4 Posters 13 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 7818892
    wrote on last edited by
    #1

    Hi folks This expression works fine without the where clause: var someQuery = from some in context.OGsome where ((some.Due_Date >= some.Base_Date.Value.AddDays(-70)) && (some.Due_Date <= some.Base_Date.Value.AddDays(+70)) ) select some; I am trying to limit the query to between +/- 70 days. I keep getting an exception. Many thanks for any help resolving this. Mike

    P B M 4 Replies Last reply
    0
    • M Member 7818892

      Hi folks This expression works fine without the where clause: var someQuery = from some in context.OGsome where ((some.Due_Date >= some.Base_Date.Value.AddDays(-70)) && (some.Due_Date <= some.Base_Date.Value.AddDays(+70)) ) select some; I am trying to limit the query to between +/- 70 days. I keep getting an exception. Many thanks for any help resolving this. Mike

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      What is the exception?

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      1 Reply Last reply
      0
      • M Member 7818892

        Hi folks This expression works fine without the where clause: var someQuery = from some in context.OGsome where ((some.Due_Date >= some.Base_Date.Value.AddDays(-70)) && (some.Due_Date <= some.Base_Date.Value.AddDays(+70)) ) select some; I am trying to limit the query to between +/- 70 days. I keep getting an exception. Many thanks for any help resolving this. Mike

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        Is that column a DATETIME in the database? Is some.Base_Date something which can be known at the time the expression is compiled into a SQL query? Try storing the bounds in local variables.

        1 Reply Last reply
        0
        • M Member 7818892

          Hi folks This expression works fine without the where clause: var someQuery = from some in context.OGsome where ((some.Due_Date >= some.Base_Date.Value.AddDays(-70)) && (some.Due_Date <= some.Base_Date.Value.AddDays(+70)) ) select some; I am trying to limit the query to between +/- 70 days. I keep getting an exception. Many thanks for any help resolving this. Mike

          M Offline
          M Offline
          Matt T Heffron
          wrote on last edited by
          #4

          So it appears that Due_Date and Base_Date are both columns in the DB (properties in the Entity object?) Why do you use the .Value property with Base_Date and not with Due_Date? Are they both Nullable? What happens if either is null? (An exception? hint, hint)

          1 Reply Last reply
          0
          • M Member 7818892

            Hi folks This expression works fine without the where clause: var someQuery = from some in context.OGsome where ((some.Due_Date >= some.Base_Date.Value.AddDays(-70)) && (some.Due_Date <= some.Base_Date.Value.AddDays(+70)) ) select some; I am trying to limit the query to between +/- 70 days. I keep getting an exception. Many thanks for any help resolving this. Mike

            M Offline
            M Offline
            Matt T Heffron
            wrote on last edited by
            #5

            So...did it get solved?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups