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. dd/mm/yyyy

dd/mm/yyyy

Scheduled Pinned Locked Moved Database
databasetutorialhelp
5 Posts 4 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.
  • C Offline
    C Offline
    charleslau2855
    wrote on last edited by
    #1

    hi, anyone know how to search the date by "dd/mm/yyyy" in sql query! my code is : Select datamonth from datemonthtest where datamonth >= #" & strdatefrom & "# and datamonth <=#" & strdateto "# and data type i set it to date/time! The result is not efficient to select the month! Example: when i select the date is from 01/10/2006 to date 30/10/2006 but all the previous month will be come out! 09/08/2006...... Please help!

    N A C 3 Replies Last reply
    0
    • C charleslau2855

      hi, anyone know how to search the date by "dd/mm/yyyy" in sql query! my code is : Select datamonth from datemonthtest where datamonth >= #" & strdatefrom & "# and datamonth <=#" & strdateto "# and data type i set it to date/time! The result is not efficient to select the month! Example: when i select the date is from 01/10/2006 to date 30/10/2006 but all the previous month will be come out! 09/08/2006...... Please help!

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Select datamonth from datemonthtest where datamonth BETWEEN strdatefrom AND strdateto


      only two letters away from being an asset

      1 Reply Last reply
      0
      • C charleslau2855

        hi, anyone know how to search the date by "dd/mm/yyyy" in sql query! my code is : Select datamonth from datemonthtest where datamonth >= #" & strdatefrom & "# and datamonth <=#" & strdateto "# and data type i set it to date/time! The result is not efficient to select the month! Example: when i select the date is from 01/10/2006 to date 30/10/2006 but all the previous month will be come out! 09/08/2006...... Please help!

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

        charleslau2855 wrote:

        anyone know how to search the date by "dd/mm/yyyy" in sql query!

        select convert(varchar(10), getdate(),101)


        "My advice to you is to get married. If you find a good wife, you will be happy; if not, you will become a philosopher." Socrates

        C 1 Reply Last reply
        0
        • A albCode

          charleslau2855 wrote:

          anyone know how to search the date by "dd/mm/yyyy" in sql query!

          select convert(varchar(10), getdate(),101)


          "My advice to you is to get married. If you find a good wife, you will be happy; if not, you will become a philosopher." Socrates

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          albCode wrote:

          charleslau2855 wrote: anyone know how to search the date by "dd/mm/yyyy" in sql query! select convert(varchar(10), getdate(),101)

          That does not "search". It formats. The original question has a false lead in it by requesting a specific format. Date searches are format free because SQL Server does not store the date in a specific locale.


          Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

          1 Reply Last reply
          0
          • C charleslau2855

            hi, anyone know how to search the date by "dd/mm/yyyy" in sql query! my code is : Select datamonth from datemonthtest where datamonth >= #" & strdatefrom & "# and datamonth <=#" & strdateto "# and data type i set it to date/time! The result is not efficient to select the month! Example: when i select the date is from 01/10/2006 to date 30/10/2006 but all the previous month will be come out! 09/08/2006...... Please help!

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            Use parameters then you don't need to worry about date formats and it reduces your worries about a SQL Injection attack. Also, if you are going to put a date into a SQL string it is better to use the ISO format which is yyyy-mm-dd becuase it is locale independent.


            Upcoming Scottish Developers events: * We are starting a series of events in Glasgow in 2007. Are you interested in a particular subject, or as a speaker? * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog | Photos

            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