Change date format in DBI


I created my first DBI using one of Sverres articles on this topic.

The data is filled except 1 column, which is a date format column. All other columns are text, so this is pretty straight forward.

In the external database I have a value 31072008, which means abviously 31st of July 2008.

When creating the field, I chose the type Date.


My line of scripts says:  

location.setValue("x_regdate", object.get("column.1"));

But I guess some logic or formatting should be added to import this date.


What should be the right formatting and syntax to change it?





RE: Change date format in DBI

The datefield expects format YYYY-MM-DD, so you would have to reformat the date.


String regDate = object.get("column.1");
regDate = regDate.subString(4, 8) + "-" + regDate.subString(2,2) + "-" + regDate.subString(0,2);

Von: Michel Krohn-Dale 2. Feb 2012