I’m currently evaluating Servoy against our current database schema, which is very old and poorly designed, but I have to live with it for a while. Most of our Date fields are 8 character strings in ‘YYYYMMDD’ format. As well, many of our boolean fields are strings (Y or N). I would like Servoy to convert these string dates into proper datetime types and String boolean fields into proper bit values when reading the data so I can work with them in their proper form in Servoy, and then automatically convert the values back to String when writing back to the database.
I see a tab called ‘Conversion’ in the database field editor but I can’t seem to find any documention on how to use it. It looks like the place to configure this sort of thing. Can you let me know if Servoy can do this type conversion and how I can make it happen?
When your import is only to convert you could export the data and import them into the database of your choice (Servoy uses iAnywhere by default).
When you want to import data and convert it on a regular basis you could try our Data plug-in.
It will help you to read many file formats (eg. excel, csv etc.) and you can script the rest yourself (including the conversions). You can find more info at http://www.it2be.com/plugins.htm#data
you can use our conversion methods. For example , if you want a string with format YYYYMMDD to be displayed as date in a form you can use this code ( global method):
function string2date()
{
var myuglystring = arguments[0]
var mychars = myuglystring.split('')
var mydate = new Date()
mydate.setFullYear(mychars[0]+mychars[1]+mychars[2]+mychars[3],mychars[4]+mychars[5],mychars[6]+mychars[7])
return mydate
}
then string2date must be typed in toObjectMethodName property from conversion → globalMethodConvertor . This is just a sample to help you , other checks will be probably needed in a live application. The method date2string will be the other way around ( read a date and build(return ) your desired string). Welcome to the forum!