Date Formatting in Templates

TECH TIP: Date Format When DADE Search Criteria Values Are Saved in a Template

Question: I create a dataview with a criteria value as a date. Why does the template not save the date value as my local regional settings for date format?

Answer:   DADE saves the TdaCriteria value as a string in the report template. When the string is saved, it is saved in a date or date time format as a string in the format ‘YYYY/MM/DD.’  This is not going to cause a problem because the template will load this criteria value as a string and convert it to the correct format on your machine.

To step through this sequence, open up your local copy of the source in ..\RBuilder\Source\daSQL.pas.  Start in the procedure TdaCriteria.Loaded. Then step into the call to TdaCriteria.UpdateNumericValues and then the TdaCriteria.AddNumericValue inside of the call to UpdateNumericValues.  This should show you how RB loads the string from the template, then converts it to a date time, and then formats the date time based on your machine’s short date format.