0

Hi all,

Can someone tell me if this is a delphi bug? I am using a Controls.TDate to store a date and using the SysUtils.EncodeDate function to set the value.

Invoice.DateReceived := EncodeDate(2011, 03, 16);

When I store it in a MS SQL database field, it is adding 2 days to the date when the insert happens.

INSERT INTO Invoices (InvoiceId, DateReceived) VALUES (:InvoiceId, :DateReceived)
// Query is a TADOQuery object
Query.Parameters.ParamByName('InvoiceId').Value := Invoice.Id;
Query.Parameters.ParamByName('DateReceived').Value := Invoice.DateReceived;
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Wolfgan
0

Query.Parameters.ParamByName('DateReceived').AsDateTime := Invoice.DateReceived;

P.S.:
date can be increased simply, use IncDays/DecDays (in DateUtils)

Invoice.DateReceived := DateUtils.IncDays(now,2);

Edited by Wolfgan: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.