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. Database & SysAdmin
  3. Database
  4. getting date less than 3 yr.s old

getting date less than 3 yr.s old

Scheduled Pinned Locked Moved Database
cssdatabasehelp
3 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.
  • D Offline
    D Offline
    dotnetcsharpdev
    wrote on last edited by
    #1

    select myDate from myTable where myDate > datediff(yyyy,now,myDate)=> 3) I want to select date which is greater that   now - 3 years(less than 3 yr.s old) above query gives me following error:- Msg 102, Level 15, State 1, Line 5 Incorrect syntax near '=' :sigh:

    D Z 2 Replies Last reply
    0
    • D dotnetcsharpdev

      select myDate from myTable where myDate > datediff(yyyy,now,myDate)=> 3) I want to select date which is greater that   now - 3 years(less than 3 yr.s old) above query gives me following error:- Msg 102, Level 15, State 1, Line 5 Incorrect syntax near '=' :sigh:

      D Offline
      D Offline
      dotnetcsharpdev
      wrote on last edited by
      #2

      got it   :-D Posting it here if it might help anyone in future !!.. select myDate from myTable where datediff (yyyy,myDate ,getdate()) <= 3

      1 Reply Last reply
      0
      • D dotnetcsharpdev

        select myDate from myTable where myDate > datediff(yyyy,now,myDate)=> 3) I want to select date which is greater that   now - 3 years(less than 3 yr.s old) above query gives me following error:- Msg 102, Level 15, State 1, Line 5 Incorrect syntax near '=' :sigh:

        Z Offline
        Z Offline
        zeusToronto
        wrote on last edited by
        #3

        select * from yourtablename where DateDiff(year, myDate, getdate()) >= 3

        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