Start a new topic

RegEx Date Formula for Grad Date

Attached are the 2 formulas in the dictionary that our Omatic consultant setup a couple of years ago.  Now the formula stopped working.  Here is what we need...

Change MM/DD/YYYY to Class of YYYY or YY, but if the grad date (MM/DD/YYYY) is in December, so our Fall grads then the class of needs to be the following year.  So our grads from December (12/16/2018) should have a class year of 2019. Right now we are getting the same year, but 2 years ago it was working and giving us the following year.  Does anyone know what we may be missing?


Thank you!

docx
1 Comment

Evelyn, only a personal preference but I would have used a different approach.  In the 'afterdictionary' section of your code I would insert something like the below (note: this is not tested nor probably the correct syntax as it is off-the-cuff but the logic would work).


 'XX is whatever your column name is of the grad date

''YY is whatever your column is for the Class

if Left(import.fields.getbyexcelname("XX").Value,2)="12" then

  import.fields.getbyexcelname("YY").Value=CInt(Right(import.fields.getbyexcelname("XX").Value,4))+1

Else

   import.fields.getbyexcelname("YY").Value=Right(import.fields.getbyexcelname("XX").Value,4)

EndIf


The above basically reads as "if the grad month is 12 then their Class is the 1 + the grad year otherwise the Class is the grad year'.  There are lots of different ways to code it including error/data checking/validity/etc but think you get the gist.

Login to post a comment