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;

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);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.