Date Problem in sql Server 2008 R2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jackaal
    New Member
    • Feb 2013
    • 1

    Date Problem in sql Server 2008 R2

    Hello Friends,
    I have some problem in sql server.
    i created a storeprocedure with compare table [column] date witch difine varchar() and compare to getdate(). when compare it not proper work it gives only current month proper result not[previous or next month]....

    here is my query....

    Code:
    update tablename
    set DatalinkStatus='Visit Not Successfully' where convert(varchar(10),CallingDateAgree,103)<convert(varchar(10),getdate(),103) and status='disable'
    Thanks...
    Last edited by Rabbit; May 1 '13, 03:30 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    Dates should be compared as dates, not strings. If you're going to convert dates to strings, then you need to put the string in a format where the unit of time goes from largest to smallest from left to right.
    Last edited by Rabbit; May 1 '13, 03:34 PM.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Here, read this...

      Good Luck!!!


      ~~ CK

      Comment

      Working...