Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Hey, In a visual basic.net I am working on, I need to select rows whose column value is in between two dates. The program gets the dates in the code so they are always dynamic.

    An example query would look like

    Code:
    SELECT * FROM users WHERE (last_login BETWEEN '1/06/2005' AND '30/06/2005'
    It returns rows whose last_login column value is between those dates, but also returns a row whose last_login column is 27/05/2005

    Any ideas? the column type is date, will I have to change it to string?

    Cheers

  2.  

  3. #2
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,657
    Member #
    1234
    Liked
    137 times
    sounds like it's comparing them as numbers, not dates.
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  4. #3
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Thanks for reply Wired, I have got round that problem, I think. It does not show the 27/05/2005 row.

    My next issue is to select a row if the column last_login is in the current week. For instance if a row's last_login was 3/4/2005 (and the 3rd is a wednesday)so my sql would be
    select * from users where last_login between ('1/4/2005' and '7/4/2005')

    As before the program calculates the first date (beginning of week) and second week (end of week) but the query returns now rows, it should return 3..

    Code:
    SELECT * FROM users WHERE (last_login BETWEEN '" + startDate + "' AND '" + endDate + "')"
    Thats right so how come it will not work?


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:53 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com