Access to DateTime Structs

Discussion in 'Basic4ppc Wishlist' started by berndgoedecke, Jul 24, 2008.

  1. berndgoedecke

    berndgoedecke Active Member Licensed User

    Hello,
    is it possible to access the DateTime Structs, Methods etc.(DateTime-Member (System)) with the Door Library or is a special DateTime Libraray needed to convert VB2005- or B4P-Date to other formated DateTime Typs like Borland TDateTime ?

    best regards

    berndgoedecke
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Most properties and methods are already implemented in Basic4ppc (all the data / time keywords).
    Which method do you need?
     
  3. berndgoedecke

    berndgoedecke Active Member Licensed User

    Hello Erel,
    I need a Method to convert to Borland TDateTime, because I had a Look at SQLite-Expert, the program you advise in a Thread about SQLite.
    This program casts TDateTime as a Formated Date-String. Also Filippos ListView is able to cast a TDateTime Value as a formated String. So it should be nice to have a conversion Method, without handling a lot of binary operations.

    Best regards

    berndgoedecke
     
  4. agraham

    agraham Expert Licensed User

    From Googling
    In B4ppc a DateTime is a double representing the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001.

    So
    Code:
    Sub App_Start   
       
    Msgbox(TicksToTDateTime(TimeAdd(DateParse("01/01/1900"),18,0,0)))
       
    Msgbox(TicksToTDateTime(TimeAdd(DateParse("01/01/1996"),0,0,0)))
       
    Msgbox(Date(TDateTimeToTicks(2.75)) & " " &  Time(TDateTimeToTicks(2.75)))
       
    Msgbox(Date(TDateTimeToTicks(35065)) & " " &  Time(TDateTimeToTicks(35065)))   
    End Sub

    Sub TicksToTDateTime(ticks)
       dt = ticks - DateParse(
    "12/30/1899"' change date start
       days = Int(dt/cTicksPerDay)
       dayfraction = (dt 
    Mod cTicksPerDay) / cTicksPerDay 
       
    Return days + dayfraction
    End Sub

    Sub TDateTimeToTicks(TDateTime)
       
    Return TDateTime * cTicksPerDay + DateParse("12/30/1899")
    End Sub
     
  5. berndgoedecke

    berndgoedecke Active Member Licensed User

    Hello Agraham,
    first thank you for the reply. After googeling the TDateTime Type, my first intention was similar to yours: Convert the String to a double Value and the appearance in SQLite-Expert and ListView should be ok.
    But the following happens:
    Have a look at the first jpg: There is shown how the value is put to the table.
    The second jpg shows the DateTime-value(Lieferdatum) in the ListView.
    The third jpg shows the DateTime-value(Lieferdatum) in SQLite-Expert, but it has been interpreted as a 0 value (1899-12-30)
    In the fourth jpg the values(Lieferdatum) are changed by using SQLite-Expert.
    The fifth picture shows the changed values in the ListView.
    And I wonder !
    Where is the difference, are there different Mantisse-Bits in the double ?
    Or is there another mistake ?

    best regards

    berndgoedecke
     

    Attached Files:

  6. agraham

    agraham Expert Licensed User

    It seems to be Versanddattum that is zero in the third jpg, not Lieferdatum. All the Lieferdatum entries seem to be consistent and accurate, as are the Betelldatum, just displayed differently. The first Listview shows them as a TDateTime number, presumably before putting in the database. The last Listview shows them as a parsed string, presumably because that is how it is returned from the database. Contrary to what you said earlier "Also Filippos ListView is able to cast a TDateTime Value as a formated String" I don't think this is true. I don't think Listview converts anything, I think it just displays what it is given.
     
  7. berndgoedecke

    berndgoedecke Active Member Licensed User

    Ok it was my mistake, right is DateTime-value(Versanddatum), but the first Listview(second jpg) has the same source-table as the SQLite Expert table(third jpg), where the date values seems to be zero(but they aren't, because this is the hex code of the value: 0000 2C84 5D40 CB42 (this is not the hex of a formated String)).
    Also the Tables in jpg No.4 and No.5 has the same source-table
    Some rare informations about the new ListView value-casting can be found here,(http://www.basic4ppc.com/forum/german-forum/352-listview-dll-5.html#post13265) but only in german and in the SourceCode of fgexplorer http://www.basic4ppc.com/forum/share-your-creations/2511-fgexplorer.html#post13867
    There is a new object named Column Type
    Coltype.New1
    so the AddColumn parameters has changed:
    Case "Datetime"
    lv.AddColumn(SpNam(i),-1, 0, true, Coltype.cDateTime)
    Coltype. shows the avaliable Column Typs.
    I think Filippos DLL is right because the values, saved by SQLite-Expert are shown in the right way.

    best regards

    berndgoedecke
     
  8. agraham

    agraham Expert Licensed User

    I'm afraid that I am totally confused as to what your problem is :confused: The Lieferdatum values which are TDateTimes seem to carry through consistently. The Versanddattum values, which are also TDateTimes show zero in the third jpg. What is the difference between the two columns?
     
  9. berndgoedecke

    berndgoedecke Active Member Licensed User

    Now I understand where your confusion comes from.
    Lieferdatum is column-type= Date (where no fraction part of double is needed)
    Versanddatum is column-type = Datetime or timestamp ( where fraction part is essentaly needed to show the time-part of timestamp or date time).

    best regards

    berndgoedecke
     
  10. agraham

    agraham Expert Licensed User

    I'll have to give up on this one as I know little about SQLite. The TDateTime conversion looks OK. It looks like some sort of campatibilty issue with SQLite Expert (but you knew that already!). Maybe some SQLite expert can step into the breach?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice