Start a new topic

Two digit dates to Four digit dates

Hi there, I am a very new user to ImportOmatic, and I have what may seems like a simple question, but it's causing me quite a bit of trouble. The data that we receive from our patient records department contains patient birth date and patient admission dates with two digit years (e.g. 1980 = 80). I'd lie to create a dictionary to convert these dates to four digit years. The problem is this - right now, all of our birth dates will be 19XX due to the patient data constraints we're using, and all of the admission dates will be 20XX. Can create a dictionary that will convert the birth date column to four digit starting with 19, and the admission date column to four digit starting with 20? Also, what would happen if we had both 19XX and 20XX dates in the same column?

Although you could probably do this with a dictionary it is probably best done with a custom function.

Regular Expressions (and therfore Dictionaries) do not understand dates as dates but rather just a sequence of numbers and slashes. Therefore you can't use the concept of "before" or "after" or event day, month, year.

With a custom function you can have Visual Basic interpret the data as a date and process it accordingly (like saying "if adding 19 would make it more than 10 years ago then add 20 instead")

See this thread that talks about dates and custom functions

Thanks Wayne, very helpful. Now I just need to figure out the "If" "Then" sequence we'll need to use.

Visual Basic has a lot of date manipulation functions that you can look up online.

I would try something like this:
[code] Dim sReturn As String = oField.Value Dim MyDateTime As DateTime = DateTime.Parse(sReturn) Return MyDateTime.ToString("d") [/code]
Login or Signup to post a comment