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. Database & SysAdmin
  3. Database
  4. Problem with between function with date timepicker

Problem with between function with date timepicker

Scheduled Pinned Locked Moved Database
databasehelpsql-serversysadmin
3 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.
  • N Offline
    N Offline
    nazimghori
    wrote on last edited by
    #1

    hello i am using SQL server 2005 as my back end now i want report of like from this date to this date...for that i wrote query like format of my date is dd/MMM/yyyy If optn1.Checked = True Or optn3.Checked = True Then sqlstr="select * from des_mast" sqlstr = sqlstr & "where pickup_date between '" & Me.dtp1.Value & "' and '" & Me.dtp2.Value & "'" End If but while executing this query shows an error message like "incorrect syntax near the keyword 'between'" please suggest i cant get where the problem is thank you

    B A 2 Replies Last reply
    0
    • N nazimghori

      hello i am using SQL server 2005 as my back end now i want report of like from this date to this date...for that i wrote query like format of my date is dd/MMM/yyyy If optn1.Checked = True Or optn3.Checked = True Then sqlstr="select * from des_mast" sqlstr = sqlstr & "where pickup_date between '" & Me.dtp1.Value & "' and '" & Me.dtp2.Value & "'" End If but while executing this query shows an error message like "incorrect syntax near the keyword 'between'" please suggest i cant get where the problem is thank you

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      Try to debug and follow debugger line and then you will find the problem.


      I Love T-SQL "Don't torture yourself,let the life to do it for you." If my post helps you kindly save my time by voting my post.

      1 Reply Last reply
      0
      • N nazimghori

        hello i am using SQL server 2005 as my back end now i want report of like from this date to this date...for that i wrote query like format of my date is dd/MMM/yyyy If optn1.Checked = True Or optn3.Checked = True Then sqlstr="select * from des_mast" sqlstr = sqlstr & "where pickup_date between '" & Me.dtp1.Value & "' and '" & Me.dtp2.Value & "'" End If but while executing this query shows an error message like "incorrect syntax near the keyword 'between'" please suggest i cant get where the problem is thank you

        A Offline
        A Offline
        AlexeiXX3
        wrote on last edited by
        #3

        nazimghori wrote:

        format of my date is dd/MMM/yyyy

        The format of your sql or the format of your datetimepicker?

        nazimghori wrote:

        If optn1.Checked = True Or optn3.Checked = True Then

        You dont need to compare a booleanvalue with true or false Just do it like this: If optn1.Checked Or optn3.Checked Then Or even better: If optn1.Checked OrElse optn3.Checked Then

        nazimghori wrote:

        sqlstr="select * from des_mast" sqlstr = sqlstr & "where pickup_date between '" & Me.dtp1.Value & "' and '" & Me.dtp2.Value & "'"

        After concatenating this, i dont think youll get a space between des_mast and where, youll get des_mastwhere Also, have you tryed using # for the date values: between #12/12/2009# and #12/12/2009# If you still cant get it to work, you can test manually the query in sql server managment studio

        Alexei Rodriguez

        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