Re: ODBC
- Posted by "Carl W." <euphoria at cyreksoft.yorks.com> Sep 29, 2003
- 571 views
George Walters wrote: > I'm setting up to try and use Matt's ODBC and connect to MySQL for a > database. In reviewing what I need to do I've found a point of confusion > in how I've been handeling dates and how MySQL handle's dates. I've been > using a "sub sequence" in my record when using EUDB. as below. > > {a,b,c,{2003,09,29},e,f.....} > > this is quite convenient for dates to use the DateTime library (from > user contributions) of functions I found in the archives. The problem is > that MySQL uses yyy-mm-dd format. Is anyone doing this or has a > suggestion on what happens when this is sent to MySQL. Hopefully there > is a solution or a better way to solve this issue. Passing a Date as a sub-sequence to MySQL probably will likely pass the database three junk characters - not what you want. If your Date is in variable 'd' then you'll want to do: {a,b,c,sprintf("%04d-%02d-%02d",d),e,f.....} Reading back into a date is a bit more tricky and you'll need to use Euphoria's get.e to parse the string back into a Date: include get.e sequence s, temp Date d s = ??? -- get the stringified date from the db here temp = value(s[1..4]) & value(s[6..7]) & value(s[9..10]) d = temp[2] & temp[4] & temp[6] There's no error checking in the above code. Look up value() and GET_SUCCESS / GET_FAIL in the Euphoria docs if you need to check that things are being parsed correctly. The status codes in the above snippet would be in temp[1], temp[3] and temp[5] respectively. HTH, Carl -- [ Carl R White == aka () = The Domain of Cyrek = ] [ Cyrek the Illogical /\ www.cyreksoft.yorks.com ]