Skip to main content

Search

Search

Adding value to an inputted date

Comments

1 comment

  • Avatar
    Scott Mason

    I found out how to do it. 

    First I had to add the field I was adding, in my case months, as a field on the label template. I moved it off to the side so it was unprinted. Then I set its data type to be integer and gave it a datasource name. 

    Once it had a name I can use it in the script as an integer.  I tried converting it in the script but it didn't work, putting it on the label and setting the type was the trick. 

    Next there is a function called DateValue that gets a date from an input apparently that I needed to use. 

    Dim monthsToAdd
    monthsToAdd = Format.NamedSubStrings("ShelfLife").Value

    Dim theCureDate
    theCureDate = DateValue(Format.NamedSubStrings("Cure").Value)

    If monthsToAdd < 0 Then

    'Return the word unlimited
    Value = "Unlimited"

    Else

    'Calculate expiration date
    Value = DateAdd("m", monthsToAdd, theCureDate)

    End If
    0

Please sign in to leave a comment.