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. Visual Basic
  4. date time matching

date time matching

Scheduled Pinned Locked Moved Visual Basic
databaseregextutorial
7 Posts 3 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.
  • _ Offline
    _ Offline
    _tasleem
    wrote on last edited by
    #1

    had inserted datetime values in databse field like '" + DateTime.now + "' now i want to comapre valus using betwwen operator of SQL i.e where dbtime between '" + dtp1.value + "' AND '" + dtp2.value + "' but it does not show any record i think critera of where class did not match. how to compare them so that it show correct result Tasleem Arif

    A 1 Reply Last reply
    0
    • _ _tasleem

      had inserted datetime values in databse field like '" + DateTime.now + "' now i want to comapre valus using betwwen operator of SQL i.e where dbtime between '" + dtp1.value + "' AND '" + dtp2.value + "' but it does not show any record i think critera of where class did not match. how to compare them so that it show correct result Tasleem Arif

      A Offline
      A Offline
      Asif Sayed
      wrote on last edited by
      #2

      Can you paste your code here? might be easy to help you that way. Difficult - > Challenging, this simple replacement made me take my life little easy;)

      _ 1 Reply Last reply
      0
      • A Asif Sayed

        Can you paste your code here? might be easy to help you that way. Difficult - > Challenging, this simple replacement made me take my life little easy;)

        _ Offline
        _ Offline
        _tasleem
        wrote on last edited by
        #3

        str="INSERT INTO tblHistoryLog(UserId,UserAction,TableName,ActionDate,TrDoneOn) VALUES('" + CheckValues.strUserId + "','NEW RECORD','USER TABLE','" + DateTime.Now + "','" + cmbTAUserId.Text + "')"; where ActionDate datatype if datetime. i had inserted record in the table and inserted properly. the query that uses the comparison "SELECT * FROM tblHistoryLog WHERE (ActionDate BETWEEN #"+ dtpTo.Value +"# AND #"+ dtpFrom.Value +"#)" but it gives the no result i had tried to use this but it does not compile so i had to use above "+ #dtpTo.Value# +" AND "+ #dtpFrom.Value# +" Tasleem Arif

        G A 2 Replies Last reply
        0
        • _ _tasleem

          str="INSERT INTO tblHistoryLog(UserId,UserAction,TableName,ActionDate,TrDoneOn) VALUES('" + CheckValues.strUserId + "','NEW RECORD','USER TABLE','" + DateTime.Now + "','" + cmbTAUserId.Text + "')"; where ActionDate datatype if datetime. i had inserted record in the table and inserted properly. the query that uses the comparison "SELECT * FROM tblHistoryLog WHERE (ActionDate BETWEEN #"+ dtpTo.Value +"# AND #"+ dtpFrom.Value +"#)" but it gives the no result i had tried to use this but it does not compile so i had to use above "+ #dtpTo.Value# +" AND "+ #dtpFrom.Value# +" Tasleem Arif

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          What database are you using? What is the data type of the field in the database? --- b { font-weight: normal; } -- modified at 8:07 Saturday 8th July, 2006

          _ 1 Reply Last reply
          0
          • G Guffa

            What database are you using? What is the data type of the field in the database? --- b { font-weight: normal; } -- modified at 8:07 Saturday 8th July, 2006

            _ Offline
            _ Offline
            _tasleem
            wrote on last edited by
            #5

            datatype is datetime and i m using sql server2000 Tasleem Arif

            G 1 Reply Last reply
            0
            • _ _tasleem

              datatype is datetime and i m using sql server2000 Tasleem Arif

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              Then you shouldn't use # arounds the date values. That is use with MS Access. --- b { font-weight: normal; }

              1 Reply Last reply
              0
              • _ _tasleem

                str="INSERT INTO tblHistoryLog(UserId,UserAction,TableName,ActionDate,TrDoneOn) VALUES('" + CheckValues.strUserId + "','NEW RECORD','USER TABLE','" + DateTime.Now + "','" + cmbTAUserId.Text + "')"; where ActionDate datatype if datetime. i had inserted record in the table and inserted properly. the query that uses the comparison "SELECT * FROM tblHistoryLog WHERE (ActionDate BETWEEN #"+ dtpTo.Value +"# AND #"+ dtpFrom.Value +"#)" but it gives the no result i had tried to use this but it does not compile so i had to use above "+ #dtpTo.Value# +" AND "+ #dtpFrom.Value# +" Tasleem Arif

                A Offline
                A Offline
                Asif Sayed
                wrote on last edited by
                #7

                I assume that you are using either ASP.NET or windows forms as client. Try following: "ActionDate BETWEEN" & " '" & Convert.ToDateTime(dtpFrom.Value).ToLongDateString & "' AND " & " '" & Convert.ToDateTime(dtpTo.Text).ToLongDateString & "'" I also notice in your code, you are going from To...From! usually it is From...To right? Hope this helps. Difficult - > Challenging, this simple replacement made me take my life little easy;)

                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