Skip to main content

Search

Search

Type mismatch for date

Comments

2 comments

  • Avatar
    Peter Thane

    Are you performing the VB as an Event Controlled Script? It looks like you are bringing the data in from a database field and so you need to make sure the VB routine runs after this (such as OnNewReicord, OnPostPrompt or OnIdenticalCopies.

    It looks like you will need to make the sub-type of the VB field Date and adjust the format afterwards as without this, in my testing the VB date came out as DD/MM/YYYY (my PC's standard date order)

    0
  • Avatar
    Scott Mason

    Here's what I finally did to get it working:

    sl = Field("ShelfLife_c") 
    d = Field("MfgDt")

    ' make sure d is a date and there is a valid shelf life
    if ( IsDate(d) and sl > 0 ) then

    'convert to date obj
    dob = CDate(d)

    ' create the expiration date by adding shelf life to the mfg date
    d = DateAdd("m", sl , dob)

    'output needs to be MMDDDD, DatePart function will not zero pad so use Right to zero pad month then concatenate the year
    Value = Right("00" & DatePart("m", d), 2) & DatePart("yyyy", d)

    else

    ' otherwise just return a string of zeros
    Value = "000000"

    end if
    0

Please sign in to leave a comment.