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. Web Development
  3. ASP.NET
  4. db query

db query

Scheduled Pinned Locked Moved ASP.NET
databasehelp
2 Posts 2 Posters 0 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.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi, I have a db table that has a date field for each record,say audate, that records the date and time when a particular record is added or updated. I want to list all the records that are added or updated in past two days... I wrote the query as.. q_str = " select * from tab1 where audate > " + System.DateTime.Now.AddDays(-2) + ""; But it gave me error that it could'nt resolve the query... How should I write my query... Thanks a lot..

    D 1 Reply Last reply
    0
    • A Anonymous

      Hi, I have a db table that has a date field for each record,say audate, that records the date and time when a particular record is added or updated. I want to list all the records that are added or updated in past two days... I wrote the query as.. q_str = " select * from tab1 where audate > " + System.DateTime.Now.AddDays(-2) + ""; But it gave me error that it could'nt resolve the query... How should I write my query... Thanks a lot..

      D Offline
      D Offline
      Dan_P
      wrote on last edited by
      #2

      After your line of code, q_str will contain "select * from tab1 where audate > 01/05/2005", this isn't valid SQL, the date part needs to escaped like: q_str = " select * from tab1 where audate > """ + System.DateTime.Now.AddDays(-2) + """; Even then depending on the database, you might need to format the date like YYYY-MM-DD.

      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