DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How to compare dates to get desired results... ?

  1. #1
    Jaikumar Sharma Guest

    How to compare dates to get desired results... ?


    Hi,

    Through visual basic, i am taking two dates as input and later I am searching
    these dates in a table in SQL server. I am using BETWEEN keyword for this.
    My query works fine and I get the desired results while in SQL enterprise
    Manager, but when I compare these dates through VB in SQL table, i do not
    get desired results.

    My Syntax for this is Like this :

    Select tablename.fieldname1,tablename.fieldname2 from ACUTALTABLE
    where !fieldname = 111 and fielddate between userinptDate1 >=
    !TableDate and userinptdate2 <= !TableDate.

    Is this syntax is correct ?

    Thanks in advance..










  2. #2
    Mirad Maglic Guest

    Re: How to compare dates to get desired results... ?


    The problem IS in your syntax.

    The BETWEEN...AND keywords are acctualy an imlicit combination of >= and
    <= operators, so the correct syntax would look something like:

    Select tablename.fieldname1,tablename.fieldname2 from ACUTALTABLE
    where !fieldname = 111 and !TableDate between userinptDate1 and userinptdate2;

    HTH

    Mirad

    "Jaikumar Sharma" <jaikumar.sharma@barco.com> wrote:
    >
    >Hi,
    >
    >Through visual basic, i am taking two dates as input and later I am searching
    >these dates in a table in SQL server. I am using BETWEEN keyword for this.
    >My query works fine and I get the desired results while in SQL enterprise
    >Manager, but when I compare these dates through VB in SQL table, i do not
    >get desired results.
    >
    >My Syntax for this is Like this :
    >
    >Select tablename.fieldname1,tablename.fieldname2 from ACUTALTABLE
    >where !fieldname = 111 and fielddate between userinptDate1 >=
    >!TableDate and userinptdate2 <= !TableDate.
    >
    >Is this syntax is correct ?
    >
    >Thanks in advance..
    >
    >
    >
    >
    >
    >
    >
    >
    >



  3. #3
    jaikumar sharma Guest

    Re: How to compare dates to get desired results... ?


    Thanks Mirad...

    "Mirad Maglic" <mirad@pinx.net> wrote:
    >
    >The problem IS in your syntax.
    >
    >The BETWEEN...AND keywords are acctualy an imlicit combination of >= and
    ><= operators, so the correct syntax would look something like:
    >
    >Select tablename.fieldname1,tablename.fieldname2 from ACUTALTABLE
    >where !fieldname = 111 and !TableDate between userinptDate1 and userinptdate2;
    >
    >HTH
    >
    >Mirad
    >
    >"Jaikumar Sharma" <jaikumar.sharma@barco.com> wrote:
    >>
    >>Hi,
    >>
    >>Through visual basic, i am taking two dates as input and later I am searching
    >>these dates in a table in SQL server. I am using BETWEEN keyword for this.
    >>My query works fine and I get the desired results while in SQL enterprise
    >>Manager, but when I compare these dates through VB in SQL table, i do not
    >>get desired results.
    >>
    >>My Syntax for this is Like this :
    >>
    >>Select tablename.fieldname1,tablename.fieldname2 from ACUTALTABLE
    >>where !fieldname = 111 and fielddate between userinptDate1 >=
    >>!TableDate and userinptdate2 <= !TableDate.
    >>
    >>Is this syntax is correct ?
    >>
    >>Thanks in advance..
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center