Changing a character date field to a date field
Forums
Date fields can come in many different varieties. Visual Basic has a function called CDate that is able to figure out the majority of the formats and translate them into a common format. The following is the code for a custom function to do the change.
Option Explicit
Function CtoDate(p1 As String) As Date
ctodate = CDate(p1)
End Function
Hello,
Hello,
The attached text file contains the equation you need. Open the text file and copy and paste the contents into the equation editor of IDEA. It uses @ctod, but also uses @getat and @insert to insert leading zeroes for months and days that are missing them.
You will need to use the equation editor's find/replace button. 5th from the left on the equation editor toolbar to replace my generic field name with your date's field name.
The return for this equation is mm/dd/yyyy. This can be tweaked to dd/mm/yyyy if you happen to come across that format as well. Simply change the date mask inside the quotation marks at the end of the equation.
Also, if your separator in the field is something other than /, say a hyphen -, you can also use find and replace to edit the separator.
Cheers,
Steve
I think this doesn't work if
I think this doesn't work if you're importing using SQL server and the dates come as Numeric in a format that IDEA can't understand. You'll use these and other formulae but you'll end up with "Error" for each record of the field. Currently my problem, but I've had to export my databases to Access where I can fix that.