Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Problem sending dates via a TServerRequest from a TDateEditComboBox
Fri, Nov 22 2019 4:58 AMPermanent Link

Paul Coshott

Avatar

Hi All,

I am sending data to my XData server using a TServerRequest. Everything is working well except for 1 thing. The JSON being created varies for the date value.

If I load my client edit form by using:

   edtDOB.SelectedDate := Client.DOB;

Client is a persistent class and DOB is defined as DateTime.

If I don't make any changes to the date, it sends it across to the server correctly. But if I change the date by dropping down the calendar and then sending it across to the server, it sends a different Unix date number, which causes the server to save the previous days date.

With no change to the date edit combo box:
17-05-1988 -> 579830400000

Choose the same date by dropping down the calendar:
17-05-1988 -> 579801600000

Anyone have any idea why this is happening?

Cheers,
Paul
Fri, Nov 22 2019 11:08 AMPermanent Link

Walter Matte

Tactical Business Corporation

Paul:

Local Date vs UTC Date

Check if using property LocalizeText helps....
TDateEditComboBox.LocalizeText

If not I use this function.....

function DateFix(dt : DateTime) : Integer;
begin
 result := (TimeZoneOffSet(dt) * 60 * 1000);
end;


TheDate :=  edtDOB.SelectedDate + DateFix(edtDOB.SelectedDate) ;


Walter



If I don't make any changes to the date, it sends it across to the server correctly. But if I change the date by dropping down the calendar and then sending it across to the server, it sends a different Unix date number, which causes the server to save the previous days date.

With no change to the date edit combo box:
17-05-1988 -> 579830400000

Choose the same date by dropping down the calendar:
17-05-1988 -> 579801600000

Anyone have any idea why this is happening?

Cheers,
Paul
Image