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. Query Help

Query Help

Scheduled Pinned Locked Moved Database
helpdatabase
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

    Please help. When I use @From it fails with the following error , but at the same time when I spesify date is runs fine. "The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value." Declare @From as varchar(10) Set @From =(case When DatePart (dw , getdate())=2 Then convert(varchar(10),(getDate()-3),101) When DatePart (dw , getdate())=4 Then convert(varchar(10),(getDate()-2),101) When DatePart (dw , getdate())=6 Then convert(varchar(10),(getDate()-2),101) Else convert(varchar(10),(getdate()),101) End ) select @From select dateentered from NormalizedData_Out n join MaxDate_Out m on n.StudentID= m.StudentID and (isnull(n.DateEntered, '1/1/1900') =isnull(m.maxdate, '1/1/1900')) and n.dateentered between @From and getdate() --and n.dateentered between '08/27/2003' and getdate()

    B 1 Reply Last reply
    0
    • S sardinka

      Please help. When I use @From it fails with the following error , but at the same time when I spesify date is runs fine. "The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value." Declare @From as varchar(10) Set @From =(case When DatePart (dw , getdate())=2 Then convert(varchar(10),(getDate()-3),101) When DatePart (dw , getdate())=4 Then convert(varchar(10),(getDate()-2),101) When DatePart (dw , getdate())=6 Then convert(varchar(10),(getDate()-2),101) Else convert(varchar(10),(getdate()),101) End ) select @From select dateentered from NormalizedData_Out n join MaxDate_Out m on n.StudentID= m.StudentID and (isnull(n.DateEntered, '1/1/1900') =isnull(m.maxdate, '1/1/1900')) and n.dateentered between @From and getdate() --and n.dateentered between '08/27/2003' and getdate()

      B Offline
      B Offline
      basementman
      wrote on last edited by
      #2

      Either declare @From as datatype smalldatetime, not varchar or use Convert(smalldatetime,@From,101) in the where clause.  onwards and upwards...

      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