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. General Programming
  3. Visual Basic
  4. dd/mm/yyyy

dd/mm/yyyy

Scheduled Pinned Locked Moved Visual Basic
databasetutorialhelp
5 Posts 5 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!

    C G 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!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I thnk DATEPART is what you need, perhaps.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      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!

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        Most likely due to the date format that you are using. The database is probably expecting the format "MM/dd/yyyy". You should use an unambigous date format like ISO 8601 ("yyyy-MM-dd"), or better yet, parameterised queries.

        --- b { font-weight: normal; }

        R 1 Reply Last reply
        0
        • G Guffa

          Most likely due to the date format that you are using. The database is probably expecting the format "MM/dd/yyyy". You should use an unambigous date format like ISO 8601 ("yyyy-MM-dd"), or better yet, parameterised queries.

          --- b { font-weight: normal; }

          R Offline
          R Offline
          Ravi kumar G
          wrote on last edited by
          #4

          use "yyyy-MM-dd" + " 00:00:00 Between "yyyy-MM-dd" + " 23:59:59 " Format

          Ravikumar [Coimbatore]

          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
            Costica U
            wrote on last edited by
            #5

            This is a piece of code you can use to convert data:

            SET DATEFORMAT dmy
            DECLARE @datevar datetime
            SET @datevar = '31/12/1998'
            SELECT @datevar

            And the result are: 1998-12-31 00:00:00.000 Hope this helps! -- modified at 9:07 Wednesday 6th December, 2006

            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