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. Date Problem

Date Problem

Scheduled Pinned Locked Moved Database
databasehelpworkspace
7 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.
  • S Offline
    S Offline
    Syed Shahid Hussain
    wrote on last edited by
    #1

    hei all, I'm now working in Norwegian environment where date formate is like this DD.MM.YYYY so when i write query in SQL 2000 like this SELECT joinDate FROM myTable WHERE (joinDate>= '01.01.2009') AND (joinDate<= '01.01.2010') it gives error And I cant convert date format. Any ideat will be most welcome. Thanks

    Syed Shahid Hussain

    J D P 3 Replies Last reply
    0
    • S Syed Shahid Hussain

      hei all, I'm now working in Norwegian environment where date formate is like this DD.MM.YYYY so when i write query in SQL 2000 like this SELECT joinDate FROM myTable WHERE (joinDate>= '01.01.2009') AND (joinDate<= '01.01.2010') it gives error And I cant convert date format. Any ideat will be most welcome. Thanks

      Syed Shahid Hussain

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      The answer is to always use ISO 8601[^] date format when dealing with databases. So your query becomes:

      SELECT joinDate
      FROM myTable
      WHERE (joinDate>= '2009-01-01') AND (joinDate<= '2010-01-01')

      S 1 Reply Last reply
      0
      • J J4amieC

        The answer is to always use ISO 8601[^] date format when dealing with databases. So your query becomes:

        SELECT joinDate
        FROM myTable
        WHERE (joinDate>= '2009-01-01') AND (joinDate<= '2010-01-01')

        S Offline
        S Offline
        Syed Shahid Hussain
        wrote on last edited by
        #3

        Thanks. But the problem is that from application how can i change the date format, should i wirite a function that get dd.mm.yyyy and then return into yyyy-mm-dd Any suggestion from u. Thanks

        Syed Shahid Hussain

        1 Reply Last reply
        0
        • S Syed Shahid Hussain

          hei all, I'm now working in Norwegian environment where date formate is like this DD.MM.YYYY so when i write query in SQL 2000 like this SELECT joinDate FROM myTable WHERE (joinDate>= '01.01.2009') AND (joinDate<= '01.01.2010') it gives error And I cant convert date format. Any ideat will be most welcome. Thanks

          Syed Shahid Hussain

          D Offline
          D Offline
          David Skelly
          wrote on last edited by
          #4

          If joinDate is a DateTime type, then this should work:

          joinDate >= CONVERT(DATETIME, '01.01.2009', 104)

          This is fully documented in the SQL Server documentation, which is all available on line.

          S 1 Reply Last reply
          0
          • D David Skelly

            If joinDate is a DateTime type, then this should work:

            joinDate >= CONVERT(DATETIME, '01.01.2009', 104)

            This is fully documented in the SQL Server documentation, which is all available on line.

            S Offline
            S Offline
            Syed Shahid Hussain
            wrote on last edited by
            #5

            oh really thanks David its great :rose:

            Syed Shahid Hussain

            1 Reply Last reply
            0
            • S Syed Shahid Hussain

              hei all, I'm now working in Norwegian environment where date formate is like this DD.MM.YYYY so when i write query in SQL 2000 like this SELECT joinDate FROM myTable WHERE (joinDate>= '01.01.2009') AND (joinDate<= '01.01.2010') it gives error And I cant convert date format. Any ideat will be most welcome. Thanks

              Syed Shahid Hussain

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Parse the strings to DateTime and use a parameterized query.

              S 1 Reply Last reply
              0
              • P PIEBALDconsult

                Parse the strings to DateTime and use a parameterized query.

                S Offline
                S Offline
                Syed Shahid Hussain
                wrote on last edited by
                #7

                thanks :rose:

                Syed Shahid Hussain

                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