substract two date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BIJOY DAS
    New Member
    • Feb 2012
    • 1

    substract two date

    I have a date field start_date.i want to substract that date from current date(machine date)and want to get the result as month
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Add this function in a Module in VBA:

    Code:
    Function MonthDiff(MYdate As Variant) As Variant
        MonthDiff = Str((DateDiff("m", Now, MYdate)))
    End Function
    Use the function (see Attachment)
    [imgnothumb]http://bytes.com/attachments/attachment/6111d1329561587/screencap-1.jpg[/imgnothumb]
    Attached Files
    Last edited by NeoPa; Feb 20 '12, 06:17 PM. Reason: Made pic viewable

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32668

      #3
      I believe the question is SQL Server (T-SQL) related Guido ;-)

      Comment

      • mohit2k8
        New Member
        • Feb 2012
        • 5

        #4
        You can use given below function in sql server..
        DATEDIFF(MM,sta rt_date,getdate ())

        Comment

        Working...