Results 1 to 4 of 4

Thread: [RESOLVED] date selection using vb6 and msaccess

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    19

    Resolved [RESOLVED] date selection using vb6 and msaccess

    hi,

    im having a problem in getting the sales based on a date range given by a user.. pls help me provide the code.. tnx

  2. #2
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: date selection using vb6 and msaccess

    The Query should similar to this:

    SELECT YourDateField.YourTable FROM YourTable WHERE
    YourDateField.YourTable > #10/10/2006# AND YourDateField.YourTable < #1/2/2007#;

    Note1: the date notation is in US style -> Month,Day,Year

    Note2: A date should be surrounded by # in a SQL query to be regognized as such

    Note3: The code to extract this query from your Access database depends on the type of connection you want to make DOA, ADO and if you want to use a datacontrol or not to bind a form/controle to this data.
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  3. #3
    Frenzied Member
    Join Date
    Aug 2006
    Location
    India, Punjab, Bhatinda
    Posts
    1,689

    Re: date selection using vb6 and msaccess

    Additionally would it not be safer to use BETWEEN instead of > or <. Further are we not to use
    format("10/10/2006",desiredformat)
    to ensure safer working with databases.
    correct me if I am wrong.

    "SELECT * FROM ORDERS WHERE orderDate BETWEEN #" & format("10/10/2006","yyyy/mm/dd") & "# AND #" & format("1/2/2007","yyyy/mm/dd") & "#"

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2007
    Posts
    19

    Re: date selection using vb6 and msaccess

    thanks pips..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width