Whats wrong with TDateTime value - c++builder

I have a TDateTime variable called currMonth. currMonth's value is "6/30/2000 11:59:59 PM".
I need to insert currMonth as default value for a field at TDBGrid called dtBegin.
I try this code :
dtBegin->AsDateTime = currMonth;
And the compiler is succeed compiling the project, but when I debug it, I get dtBegin value is not "6/30/2000 11:59:59 PM" but { 36738.9999999884 }.
Anyone know whats wrong with this TDateTime object?
Thanks in advance.

There are numerous replies to your same question that you posted on the Embarcadero forum at the same time you posted here.
In a nutshell, there is nothing wrong at all. TDateTime is implemented as a double internally. The debug inspector is merely showing you that double value as-is, not a formatted date/time string that you are expecting. This is normal behavior, and your TDateTime itself will work fine in your code. You are using an older version of C++Builder, so you do not have the TDateTime debug visualizer that newer versions of C++Builder have for displaying TDateTime values nicer, that's all.
If you need to see the TDateTime value in a formatted manner inside the debugger, you will have to define an entry in the Watch List that calls the RTL's DateTimeToStr() function, or the TDateTime::FormatString() method, and displays the result to you.

Related

Formatting Orbeon Date input fields

I am trying to format an input field of the type xs:date in Orbeon.
I have tried using the xxf:format attribute, but the datepicker can not understand the date when it has been modified.
The idea now was to change the javascript of Orbeon to use the xxf:unformat attribute to interpret the date and transform it back to ISO format.
I've tried changing the data.js but for some reason none of the changes can be seen.
Am I changing the wrong file?
Edit
I figured out that the xforms.js has a function 'getCurrentValue' which is being as the changes I do there are visible. Now I just need to figure out who is the one that's calling the function.
Edit:
It is the Calendar who requests the value of the input when the user clicks on the symbol. This all happens at the client side, and the generated HTML does not have the format/unformat attributes. However I want to use their value. Can I make a request to Orbeon to get it? How?
In case you're using an xf:input bound to a node of type xs:date, you can control the formatting of the date field with the oxf.xforms.format.input.date property. A few formats are supported, and if you want to add more, the best would be to follow the pattern currently used for the currently supported formats.
E.g.
[M]/[D]/[Y]
[Y]-[M01]-[D01]

Date format does not display correctly until app is closed and reopened

I am working on a simple database application in Delphi using FireDAC and SQLite3. Whenever I insert a new record into the database, the date format that is shown on my form is always in the format of yyyy-mm-dd and once I close and reopen the application the format changes to m/d/yyyy which is the format I was expecting and wish to always be displayed without closing and reopening my application.
The Definition Parameters and Options for the FireDAC connection are all at their default values. The DataType set for the field that holds the date in the SQLite3 database is set to DATE. Finally, the code I use to insert the record is below.
Qry.SQL.Text := 'INSERT INTO employees (HireDate) VALUES (:HiredOn)';
Qry.ParamByName('HiredOn').AsDate := DateTimePicker1.Date;
Qry.ExecSQL;
Qry.Open('SELECT * FROM employees');
Any help would be appreciated.
Make sure that any format settings for the date field in the underlying BindingSource / List / Adapter matches that of the form/grid field. It might be that the underlying binding formatting for the field is overriding your new settings for the form/grid field.
Set the format/display on your form field to "m/d/yyyy" and for good measure, *also do it through code in the InitializeGrid event handler
This is happening b/c when the date format on your form field doesn't match that in SQLite3 which is "yyyy-mm-dd". So you would need to set the format/display on your form field to match that.
Uses DateUtils ...
DateUtils.DateOf(DateTimePicker1.Date);
Try
FormatDateTime('dd/mm/yyyy', DateTimePicker1.Date);

FrameEventsArgs Time member variable is not returning rational values when I debug

When I put a breakpoint in the OnRenderFrame function and inspect the FrameEventsArgs parameter I get really large numbers for FrameEventsArgs.Time.
Numbers like 1.75842543717402E+132 which is ridiculously large. I occasionally get ridiculously small numbers too.
If I create the default GL app with monodevelop and debug it without changing anything the value is always 3.46247528645812E-317.
I'm an idiot. I guess I could blame the Xamarin people for passing the FrameEventsArgs class as a parameter to OnRenderFrame but I wont.
OnUpdateFrame gets a valid FrameEventsArgs with the Time variable properly set.

Orbeon form builder: Using date fields with initial value "current-date()"

I am using date fields in Orbeon form builder that should be prefilled with the current date (see http://i42.tinypic.com/erdjrb.jpg). When choosing a date by hand in the form, the date format in resulting XML model is set to "2011-07-12". But when not changing the default value of current-date(), then I get "2011-07-12+02:00". Does anybody know why the date format is different when I prefill it with current-date()?
Thank you!
The XPath function fn:current-date() by definition returns the date together with explicit time zone information. I assume orbeon just passes the function call to the XPath engine (Saxon i think). A quick workaround would be to format the result of current-date() using format-date(), for example:
format-date(current-date(), '[Y]-[M01]-[D01]')
Since i don't use Form Builder, i can't tell in detail, but i assume setting the config options how to format xforms:input controls regarding date and time values applies for form builder, too.

String Truncation on Transfer to ClientDataset

I'm using Firebird 2.1, DBExpress Driver from DevArt and Delphi 2010. Some of my reports that used to work with Delphi 2006 stopped working and produced an error message indicating that "arithmetic exception, numeric overflow, or string truncation" had occurred. The error occurred at this point in my code:
cds.Data := dsProvider.Data;
I found the place in my SQL statement that caused the error:
iif(ytd.hPayType <> -1,t.sCode, 'NET') sPayType
T.sCode is a Varchar(10) field. My conclusion is that the query returns data to the dsProvider and that when the dsProvider.Data is passed to the cds.Data, the cds component sets the field width based on the first value it receives. I get the same error message if I change the "iif" to a CASE statement. I managed to work around the issue by doing this:
CAST(iif(ytd.hPayType <> -1,t.sCode, 'NET') AS varchar(10)) sPayType
Since this used to work in Delphi 2006 without the CAST, I assume that the new behavior is due to an update to the TClientDataset. It would be nice to have the old, more forgiving behavior. Is there a way to configure the ClientDataset to accept this without a complaint or do I need to just tell my users to CAST on string results based on iif and CASE statements?
I used to work a lot with firebird in my last job, this error happens when you already have a large (length) varchar field value stored in the db and you are trying to "get" the string in delphi, try updating the value in the db to a smaller (length) varchar. I'm not sure if will work for you but give it a try.
Well, with a little more experience, it looks like I am seeing this truncation error show up consistently with the Delphi 2010 version of ClientDatasets. If I find a resolution that does not involve having to use CAST in the query, I will post it here. But for now, I am going to close this posting.

Resources