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. where close

where close

Scheduled Pinned Locked Moved Database
helpquestion
2 Posts 2 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
    sardinka
    wrote on last edited by
    #1

    I am getting an error msg: "The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value." when I have the following code in where close: and n.dateentered between (case When DatePart (dw , getdate())=2 Then (getDate()-3 ) When DatePart (dw , getdate())=4 Then (getDate()-2 ) When DatePart (dw , getdate())=6 Then (getDate()-2 ) Else GetDate() End ) and (getdate()-1) but when I run with this (I put dates manually) it is fine. and n.dateentered between '09/20/2003' and '09/29/2003' Any idea why?

    E 1 Reply Last reply
    0
    • S sardinka

      I am getting an error msg: "The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value." when I have the following code in where close: and n.dateentered between (case When DatePart (dw , getdate())=2 Then (getDate()-3 ) When DatePart (dw , getdate())=4 Then (getDate()-2 ) When DatePart (dw , getdate())=6 Then (getDate()-2 ) Else GetDate() End ) and (getdate()-1) but when I run with this (I put dates manually) it is fine. and n.dateentered between '09/20/2003' and '09/29/2003' Any idea why?

      E Offline
      E Offline
      Edbert P
      wrote on last edited by
      #2

      I have tested the SQL query using SQL Server Enterprise Manager and it's working fine for me. My guess is that n.dateentered is of type "smalldatetime" and GetDate actually returns "datetime" instead. You might want to try one of the following: 1. Use CAST(x as y) e.g. CAST( (case when...end) AS smalldatetime) ->I've tested this with the code and it works 2. Use DateAdd() function instead of getDate()-3 3. Use DatePart to format your date ranges to yyyymmdd format

      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