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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. January minus 2 should be November......(a little math and some SQL)

January minus 2 should be November......(a little math and some SQL)

Scheduled Pinned Locked Moved Visual Basic
databasehelptutorial
8 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.
  • J Offline
    J Offline
    Johnkokk
    wrote on last edited by
    #1

    Ok, i know it sounds ridiculous, but i am stuck here. I have 2 spineditors.The purpose is to make an SQL statement. The first(a) spineditor takes values from 1 to 12 and represents the months. The second(b) spineditor takes values from 1 to 5 and represents the latitude of the value selected in a (the number of months above and below the first spineditor). For example. If on (a) i choose 1(JANUARY) and on b 2(which means i want to get 2 months below JANUARY and 2 months above JANUARY), i want the SQL stetement to be "SELECT * from TABLE WHERE (MONTH BETWEEN 11 AND 12) OR (MONTH BETWEEN 1 AND 3)" In other words i want to select all the months from NOVEMBER to MARCH I hope you understand what i am saying here :)

    realJSOPR D 2 Replies Last reply
    0
    • J Johnkokk

      Ok, i know it sounds ridiculous, but i am stuck here. I have 2 spineditors.The purpose is to make an SQL statement. The first(a) spineditor takes values from 1 to 12 and represents the months. The second(b) spineditor takes values from 1 to 5 and represents the latitude of the value selected in a (the number of months above and below the first spineditor). For example. If on (a) i choose 1(JANUARY) and on b 2(which means i want to get 2 months below JANUARY and 2 months above JANUARY), i want the SQL stetement to be "SELECT * from TABLE WHERE (MONTH BETWEEN 11 AND 12) OR (MONTH BETWEEN 1 AND 3)" In other words i want to select all the months from NOVEMBER to MARCH I hope you understand what i am saying here :)

      realJSOPR Offline
      realJSOPR Offline
      realJSOP
      wrote on last edited by
      #2

      What does the user do if he wants November through February? And no, you didn't post your actual question - you merely gave us some criteria.

      .45 ACP - because shooting twice is just silly
      -----
      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

      J 1 Reply Last reply
      0
      • J Johnkokk

        Ok, i know it sounds ridiculous, but i am stuck here. I have 2 spineditors.The purpose is to make an SQL statement. The first(a) spineditor takes values from 1 to 12 and represents the months. The second(b) spineditor takes values from 1 to 5 and represents the latitude of the value selected in a (the number of months above and below the first spineditor). For example. If on (a) i choose 1(JANUARY) and on b 2(which means i want to get 2 months below JANUARY and 2 months above JANUARY), i want the SQL stetement to be "SELECT * from TABLE WHERE (MONTH BETWEEN 11 AND 12) OR (MONTH BETWEEN 1 AND 3)" In other words i want to select all the months from NOVEMBER to MARCH I hope you understand what i am saying here :)

        D Offline
        D Offline
        darkelv
        wrote on last edited by
        #3

        Find out the months that you want to select, from your example, -1, 0, 1, 2, 3. Then check for lower and upper boundaries, add or minus 12 accordingly. So in your example they would be 11, 12, 1, 2, 3. Then Select Where Month In (11, 12, 1, 2, 3).

        J 1 Reply Last reply
        0
        • realJSOPR realJSOP

          What does the user do if he wants November through February? And no, you didn't post your actual question - you merely gave us some criteria.

          .45 ACP - because shooting twice is just silly
          -----
          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

          J Offline
          J Offline
          Johnkokk
          wrote on last edited by
          #4

          The first spineditor is where you choose the month.The second just tells the programm to broaden the criteria of the month by so many months (spineditor b). So if he wants just November he chooses 11 on the first spineditor.But if he wants also October and December he will put 1 in the second spineditor

          L realJSOPR 2 Replies Last reply
          0
          • D darkelv

            Find out the months that you want to select, from your example, -1, 0, 1, 2, 3. Then check for lower and upper boundaries, add or minus 12 accordingly. So in your example they would be 11, 12, 1, 2, 3. Then Select Where Month In (11, 12, 1, 2, 3).

            J Offline
            J Offline
            Johnkokk
            wrote on last edited by
            #5

            Yeah that gave my brain a start. Solved.Thanks

            1 Reply Last reply
            0
            • J Johnkokk

              The first spineditor is where you choose the month.The second just tells the programm to broaden the criteria of the month by so many months (spineditor b). So if he wants just November he chooses 11 on the first spineditor.But if he wants also October and December he will put 1 in the second spineditor

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              sounds like you can only cope with an odd number of months; how about choosing October+November??? :)

              Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


              Merry Christmas and a Happy New Year to all.


              1 Reply Last reply
              0
              • J Johnkokk

                The first spineditor is where you choose the month.The second just tells the programm to broaden the criteria of the month by so many months (spineditor b). So if he wants just November he chooses 11 on the first spineditor.But if he wants also October and December he will put 1 in the second spineditor

                realJSOPR Offline
                realJSOPR Offline
                realJSOP
                wrote on last edited by
                #7

                You didn't answer my question. Your sql query is going to break if the user selects November and anything larger than 2 for the month span.

                .45 ACP - because shooting twice is just silly
                -----
                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                -----
                "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

                J 1 Reply Last reply
                0
                • realJSOPR realJSOP

                  You didn't answer my question. Your sql query is going to break if the user selects November and anything larger than 2 for the month span.

                  .45 ACP - because shooting twice is just silly
                  -----
                  "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                  -----
                  "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001

                  J Offline
                  J Offline
                  Johnkokk
                  wrote on last edited by
                  #8

                  Why will it break ? With the solution i currently have, if the user puts 11(November) and 2 for the span, i get the following numbers, after a little math : 9,10,11,12,1 Then i just make an SQL like "WHERE MONTH IN (9,10,11,12,1)" It actually works now.

                  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