Want to add a month

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • senreka2005
    New Member
    • Nov 2008
    • 4

    #1

    Want to add a month

    Hi to all,

    I want the solution for the below said problem in which I want to add month to the formated date field.

    format(dttTermi nationDate," & "'" & "mmmm-yyyy" & "'" & ")

    where dttterminationd ate is the date field & i have changed it to the format of "mmmm-yyyy"

    Kindly give the solution

    Thanks in advance

    Renuka
  • DonRayner
    Recognized Expert Contributor
    • Sep 2008
    • 489

    #2
    Originally posted by senreka2005
    Hi to all,

    I want the solution for the below said problem in which I want to add month to the formated date field.

    format(dttTermi nationDate," & "'" & "mmmm-yyyy" & "'" & ")

    where dttterminationd ate is the date field & i have changed it to the format of "mmmm-yyyy"

    Kindly give the solution

    Thanks in advance

    Renuka
    Try this

    Code:
    DateAdd("m",1,(format(dttTerminationDate," & "'" & "mmmm-yyyy" & "'" & "))

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Originally posted by senreka2005
      format(dttTermi nationDate," & "'" & "mmmm-yyyy" & "'" & ")
      I'm totally at a loss as to what you're trying to accomplish with all the ampersands and quotation marks, but I assume you're trying to add a month to

      dttTerminationD ate

      and display it in the format of

      November-2008

      When doing this kind of thing you use the DateAdd() function using the actual date field, then format the results; you don't format the date and then add to it. This should do what you're after:

      Format(DateAdd( "m",1,dttTermin ationDate),"mmm m-yyyy")

      Welcome to bytes!

      Linq ;0)>

      Comment

      • senreka2005
        New Member
        • Nov 2008
        • 4

        #4
        Originally posted by DonRayner
        Try this

        Code:
        DateAdd("m",1,(format(dttTerminationDate," & "'" & "mmmm-yyyy" & "'" & "))

        Thanks & I will check & revert back to you soon


        Renuka

        Comment

        • senreka2005
          New Member
          • Nov 2008
          • 4

          #5
          Originally posted by missinglinq
          I'm totally at a loss as to what you're trying to accomplish with all the ampersands and quotation marks, but I assume you're trying to add a month to

          dttTerminationD ate

          and display it in the format of

          November-2008

          When doing this kind of thing you use the DateAdd() function using the actual date field, then format the results; you don't format the date and then add to it. This should do what you're after:

          Format(DateAdd( "m",1,dttTermin ationDate),"mmm m-yyyy")

          Welcome to bytes!

          Linq ;0)>


          Thanks & I will check & revert back to you soon


          Renuka

          Comment

          • senreka2005
            New Member
            • Nov 2008
            • 4

            #6
            Hi,

            strSql = "select vchReferenceVal ue,vchEmployeeF irstName,vchFHG Name,dttTermina tionDate,"
            strSql = strSql & " vchReasonForLea ving,numCompens ationAmount"
            strSql = strSql & " from tbmastemployee, tbmastemployeed eductionreferen ce ,tbmastdeductio n where "
            strSql = strSql & "tbmastemployee deductionrefere nce.intrefemplo yeeid = tbmastemployee. intEmployeeId "
            strSql = strSql & "and tbmastdeduction .intdeductionid =tbmastemployee deductionrefere nce.intrefdeduc tionid and tbmastemployeed eductionreferen ce.chractivesta tus='Y' and "
            strSql = strSql & " tbmastdeduction .intdeductionid =" & gintPFID & " and format(dttTermi nationDate," & "'" & "mmmm-yyyy" & "'" & ")= Format(#" & mstrdate & "#, " & "'" & "MMMM-yyyy" & "'" & " )"



            when i give the format DateAdd("m",1,( format(dttTermi nationDate," & "'" & "mmmm-yyyy" & "'" & "))

            then it is throwing the error as Expected:end of statement kindly give me the solution for this problem

            Renuka

            Comment

            • DonRayner
              Recognized Expert Contributor
              • Sep 2008
              • 489

              #7
              Originally posted by senreka2005
              Hi,

              strSql = "select vchReferenceVal ue,vchEmployeeF irstName,vchFHG Name,dttTermina tionDate,"
              strSql = strSql & " vchReasonForLea ving,numCompens ationAmount"
              strSql = strSql & " from tbmastemployee, tbmastemployeed eductionreferen ce ,tbmastdeductio n where "
              strSql = strSql & "tbmastemployee deductionrefere nce.intrefemplo yeeid = tbmastemployee. intEmployeeId "
              strSql = strSql & "and tbmastdeduction .intdeductionid =tbmastemployee deductionrefere nce.intrefdeduc tionid and tbmastemployeed eductionreferen ce.chractivesta tus='Y' and "
              strSql = strSql & " tbmastdeduction .intdeductionid =" & gintPFID & " and format(dttTermi nationDate," & "'" & "mmmm-yyyy" & "'" & ")= Format(#" & mstrdate & "#, " & "'" & "MMMM-yyyy" & "'" & " )"



              when i give the format DateAdd("m",1,( format(dttTermi nationDate," & "'" & "mmmm-yyyy" & "'" & "))

              then it is throwing the error as Expected:end of statement kindly give me the solution for this problem

              Renuka
              You have 3 opening brackets and only 2 closing brackets, just add one more closing bracket to the end of your statement.

              Comment

              Working...