Results 1 to 6 of 6

Thread: SELECT record from to dates

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    2,171

    SELECT record from to dates

    TIPO DAL AL MM AAAA NRGG
    1-SINGOLA 23/08/2021 23/08/2021 8 2021 1
    31-SUITE 20/02/2021 28/02/2021 2 2021 9
    6-SINGOLA 03/05/2021 10/05/2021 5 2021 7
    8-SINGOLA 20/02/2021 28/02/2021 2 2021 8
    8-SINGOLA 05/01/2021 10/01/2021 1 2021 6

    i need a sql to select record between 20/02/2021 to 28/02/2021

  2. #2
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,560

    Re: SELECT record from to dates

    What's the result you're expecting? I see 2 records matching your description

    SELECT * FROM MyTable WHERE DAL=20/02/2021 AND AL=28/02/2021

    No idea about missing quotation marks. Try and error
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,438

    Re: SELECT record from to dates

    Oddly the answer was in your question...
    Quote Originally Posted by luca90 View Post
    i need a sql to select record between 20/02/2021 to 28/02/2021
    Code:
    seelct * from whateveryourtablenameissinceyoudidntprovideiyougethisinstead where icantellwhatyourdatefieldnameis between "2021-02-20" and "2021-02-28"
    I prefer the ISO format for dates when using them like this so there is no ambiguity. IF you're using parametters *koff**koff* then make sure everything is of the correct ype and it should be fine.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    2,816

    Re: SELECT record from to dates

    Quote Originally Posted by luca90 View Post
    TIPO DAL AL MM AAAA NRGG
    1-SINGOLA 23/08/2021 23/08/2021 8 2021 1
    31-SUITE 20/02/2021 28/02/2021 2 2021 9
    6-SINGOLA 03/05/2021 10/05/2021 5 2021 7
    8-SINGOLA 20/02/2021 28/02/2021 2 2021 8
    8-SINGOLA 05/01/2021 10/01/2021 1 2021 6

    i need a sql to select record between 20/02/2021 to 28/02/2021
    did you try the search or Codebank ?
    did you try a google search ?

    your here since 2005 and still end you questions with...

    i need ...
    or
    how to ?

    come on Luca, try and start programming yourself a bit
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,560

    Re: SELECT record from to dates

    Quote Originally Posted by techgnome View Post
    Oddly the answer was in your question...


    Code:
    seelct * from whateveryourtablenameissinceyoudidntprovideiyougethisinstead where icantellwhatyourdatefieldnameis between "2021-02-20" and "2021-02-28"
    I prefer the ISO format for dates when using them like this so there is no ambiguity. IF you're using parametters *koff**koff* then make sure everything is of the correct ype and it should be fine.

    -tg
    Eh?
    I'd say no.
    tg, look at his table-design (what one can derive from it)
    20/02/2021 has its own column (DAL?) compared to 28/02/2021 (AL?)
    looks like 2 columns, kinda like "StartDate - EndDate", so the BETWEEN-Operator wouldn't work
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,438

    Re: SELECT record from to dates

    Quote Originally Posted by Zvoni View Post
    Eh?
    I'd say no.
    tg, look at his table-design (what one can derive from it)
    20/02/2021 has its own column (DAL?) compared to 28/02/2021 (AL?)
    looks like 2 columns, kinda like "StartDate - EndDate", so the BETWEEN-Operator wouldn't work
    Maybe, maybe not... depends on what he's after... but with Luca... it's a 50/50 gamble... we've each taken a shot. Now we wait a couple days to see what he may or may not say. Either way I fully expect the next reply of his to throw a box of wrenches into it, expose a new requirement, or to tell us that the dates are actually strings.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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