#5 Date Format

closed
nobody
None
5
2004-09-03
2004-08-08
No

I noticed that date is saved as a raw string
(dd/mm/yyyy for UK format) instead of the SQLite yyyy-
mm-dd format.

Can anything be done to have it saved in SQLite format
as is done in SQLiteODBC engine supplied by Christian.

Best regards

Discussion

  • Nobody/Anonymous

    Logged In: NO

    Lets' assume to use SQLite 3.
    I looked inside the code and I noticed that there is no
    handling of the DbType.DateTime inside the sqlite_vm.bind
    function. The same happens with the DbTye.Decimal and with
    the DbType.Binary. When no special handling is done, all
    parameter values are converted to strings by the ToString()
    functions. In this way the date have the format defined in
    the control panel (this means ALWAYS different), the BLOBs
    are saved with the string "System.Byte[]" and the decimal
    may use a comma as decimal separator (again control panel)
    with the clear problems behind.
    The first step to the solution (put the data in the right format
    in the database) is to enhance this procedure in order to
    handle better the different types. This is easy for Decimal
    and DateTime, not so easy for the binary format (I haven't
    looked yet at the mashalling of string barameters)

     
  • Nobody/Anonymous

    Logged In: NO

    I looked at the code and I propose this modification to solve
    the problem DateTime and Decimal encoding.
    The modified function is sqlite_vm.bind

    case DbType.Double:
    case DbType.Single:
    case DbType.Decimal:
    sqlite3_bind_double(Handle,idx,Convert.ToDouble
    (aVal));
    break;

    case DbType.Int64:
    case DbType.UInt64:
    sqlite3_bind_int64(Handle,idx,Convert.ToInt64
    (aVal));
    break;

    case DbType.DateTime:
    DateTime dateVal = Convert.ToDateTime(aVal);
    if (dateVal == dateVal.Date)
    aVal = dateVal.ToString("yyyy-MM-dd");
    else
    aVal = dateVal.ToString("yyyy-MM-dd
    HH:mm:ss");
    goto default;

    Sender: Michele.Clinco@tcpos.com

     
  • Alexander Gavrilov

    Logged In: YES
    user_id=1000441

    I changed the internal representation of DateTime from
    string to Int64. Now it stores the precise number of ticks
    inside DateTime value.

     
  • Alexander Gavrilov

    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks