Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Date problem

edited March 2003 in General
Dear All,

[new to Delphi and evaluating RB]

My database contains a Serial Date field as long integer...

number of days since 30 Dec 1899
eg. 37683 = 3 Mar 2003

How can I format this to show the correct date on a report?

--
Regards, John
jkane@camozzi.co.uk

Comments

  • edited March 2003
    On the datapipeline, make sure that the TppField object (dbl-click on
    pipeline at design time to see a list of our field objects) defined for this
    datafield from your dataset has a field type set to Date. Then you can
    select the proper date format from our list of display formats in the report
    designer by right clicking over the dbText. Then the proper day should
    appear in the report for the dbText when you print the integer field as a
    date field value.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited March 2003
    Jim,

    Thank you for your reply. I'm afraid this doesn't seem to work. The database is Pervasive SQL
    2000i [Btrieve] and I have to define this field as 'Integer' in the DDFs. Some users use MS
    Access with Pass-Through Queries to access the data, and if I define the field as 'Date' an
    ODBC call fails - Invalid Date. We have to use the CDate() function in an ordinary query to
    get the correct date to display. Probably because it uses VB, which understands this date
    format.

    Back to Delphi and RB - if I change the TppField object to 'Date', it reverts back to
    'Integer' when I reconnect the Session and Database.

    If there's not an easy way round this, perhaps I could use a Calculated field, and somehow
    convert the Integer to a Date format?

    --
    Regards, John
    jkane@camozzi.co.uk

    In article <3e6394f8$1@dm500.>, "Jim Bennett \(Digital Metaphors\)" says...
  • edited March 2003
    One way to work around it other than creating a special calculated field in
    the dataset, is to create a JITPipeline to return the fields from the
    dataset. You can use the JITPipeline events to surface data from a dataset.
    This way you can define the date field type on the TppField and always
    return the integer from the query as a date field to RB. Here is an example
    of using a JIT over a query:
    http://www.digital-metaphors.com/tips/JITFromDB.zip


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited March 2003
    Thank you for pointing me to the JITPipeline example. Before getting too deeply into this, I
    tried using a 'Variable' of type dtDate. In its OnCalc event I assigned it the value of my
    Long Integer. This appears to work fine and dates are displayed correctly. Am I missing
    something, or is this a reasonable work around?

    --
    Regards, John
    jkane@camozzi.co.uk

    In article <3e64dc94$1@dm500.>, "Jim Bennett \(Digital Metaphors\)" says...
  • edited March 2003
    Ok, I didn't think of that, but yes, that is one way to handle this.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.