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. Microsoft SQL Server 2008 R2 (between)

Microsoft SQL Server 2008 R2 (between)

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelp
5 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    i'm trying to filter by date using query but error.

    select s.IdStaff, s.NamaStaff,
    sum(pd.Qty *
    case s.posisi
    when 'K.Teknisi' then kd.komisiteknisi
    when 'K.Controller' then kd.komisitelemarketing
    when 'K.Manager' then kd.komisicontroller
    when 'K.TeleMarketing' then kd.komisimanager
    when 'K.Cadangan' then kd.komisicadangan
    end) Insentif
    from staff s inner join penjualan p on s.idstaff = p.idstaff
    inner join penjualandetail pd on p.idpenjualan = pd.idpenjualan
    inner join komisidetail kd on pd.idbarang = kd.idbarang
    where p.tglpenjualan between 12/1/2011 and 12/30/2011
    group by s.idstaff, s.namastaff

    error message : Msg 206, Level 16, State 2, Line 1 Operand type clash: date is incompatible with int

    R 1 Reply Last reply
    0
    • L Lost User

      i'm trying to filter by date using query but error.

      select s.IdStaff, s.NamaStaff,
      sum(pd.Qty *
      case s.posisi
      when 'K.Teknisi' then kd.komisiteknisi
      when 'K.Controller' then kd.komisitelemarketing
      when 'K.Manager' then kd.komisicontroller
      when 'K.TeleMarketing' then kd.komisimanager
      when 'K.Cadangan' then kd.komisicadangan
      end) Insentif
      from staff s inner join penjualan p on s.idstaff = p.idstaff
      inner join penjualandetail pd on p.idpenjualan = pd.idpenjualan
      inner join komisidetail kd on pd.idbarang = kd.idbarang
      where p.tglpenjualan between 12/1/2011 and 12/30/2011
      group by s.idstaff, s.namastaff

      error message : Msg 206, Level 16, State 2, Line 1 Operand type clash: date is incompatible with int

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      Use quotes around the dates and check that the format of the dates is valid.

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      L 1 Reply Last reply
      0
      • R R Giskard Reventlov

        Use quotes around the dates and check that the format of the dates is valid.

        "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        perfect !! wondering why i always forgot that even after my teacher told me twice. how about the date format? is it YYYY/MM/DD or MM/DD/YYYY or else? thanks before.. :laugh:

        T L 2 Replies Last reply
        0
        • L Lost User

          perfect !! wondering why i always forgot that even after my teacher told me twice. how about the date format? is it YYYY/MM/DD or MM/DD/YYYY or else? thanks before.. :laugh:

          T Offline
          T Offline
          thatraja
          wrote on last edited by
          #4

          vkstarry wrote:

          how about the date format?
          is it YYYY/MM/DD or MM/DD/YYYY or else?

          SQL Server Date Formats[^]

          thatraja


          My Dad had a Heart Attack on this day so don't...
          Pompeyboy3 here
          | Nobody remains a virgin, Life screws everyone :sigh:

          1 Reply Last reply
          0
          • L Lost User

            perfect !! wondering why i always forgot that even after my teacher told me twice. how about the date format? is it YYYY/MM/DD or MM/DD/YYYY or else? thanks before.. :laugh:

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            vkstarry wrote:

            YYYY/MM/DD

            always works.

            vkstarry wrote:

            MM/DD/YYYY

            might work depending on your date settings.

            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