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 Query / "between" dates

LINQ Query / "between" dates

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqquestion
2 Posts 2 Posters 5 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
    mebjen
    wrote on last edited by
    #1

    Hi All, I've spent way to long on this - I'm trying to get distinct values from a dataTable: begDate = 2007-11-18 / endDate = 2007-12-31 Why does this work: Returns 4 rows Dim shipTo = From row In osDS.Tables(0).AsEnumerable _ Order By row(7) _ Where row(0).ToString = cust _ And row(1).ToString > begDate _ Select row(7) Distinct This doesn't work: Results Empty / Enumeration yield no results.... Dim shipTo = From row In osDS.Tables(0).AsEnumerable _ Order By row(7) _ Where row(0).ToString = cust _ And row(1).ToString < endDate _ Select row(7) Distinct But what I really want is: (but it doesn't work either) Dim shipTo = From row In osDS.Tables(0).AsEnumerable _ Order By row(7) _ Where row(0).ToString = cust _ And row(1).ToString > begDate _ And row(1).ToString < endDate _ Select row(7) Distinct Thanks in advance . . . . MB

    M 1 Reply Last reply
    0
    • M mebjen

      Hi All, I've spent way to long on this - I'm trying to get distinct values from a dataTable: begDate = 2007-11-18 / endDate = 2007-12-31 Why does this work: Returns 4 rows Dim shipTo = From row In osDS.Tables(0).AsEnumerable _ Order By row(7) _ Where row(0).ToString = cust _ And row(1).ToString > begDate _ Select row(7) Distinct This doesn't work: Results Empty / Enumeration yield no results.... Dim shipTo = From row In osDS.Tables(0).AsEnumerable _ Order By row(7) _ Where row(0).ToString = cust _ And row(1).ToString < endDate _ Select row(7) Distinct But what I really want is: (but it doesn't work either) Dim shipTo = From row In osDS.Tables(0).AsEnumerable _ Order By row(7) _ Where row(0).ToString = cust _ And row(1).ToString > begDate _ And row(1).ToString < endDate _ Select row(7) Distinct Thanks in advance . . . . MB

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

      Are begDate and endDate actually strings with the values "2007-11-18", "2007-12-31" respectively? And what is the type of data in row(1)? Is it also a string, or is it a date? If it is a date in that column, then it seems possible that taking the ToString() from date values is not using the same format as begDate and endDate are representing the date. I'd suggest doing the comparison as date (DateTime) values to avoid any issues with cultural-specific date formatting.

      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