Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread fill DBISAM TABLE with all days of 0 year
Tue, Aug 15 2017 3:07 AMPermanent Link

Paul Waegemans

IMS bvba

Avatar

What is the shortest way to fill a table with records for each day of the year

datum = 01/01/2017
datum=  02/01/2017
-
-
-
datum=  31/12/2017
Tue, Aug 15 2017 3:08 AMPermanent Link

Paul Waegemans

IMS bvba

Avatar

of 1 year of course


Paul Waegemans wrote:

What is the shortest way to fill a table with records for each day of the year

datum = 01/01/2017
datum=  02/01/2017
-
-
-
datum=  31/12/2017
Tue, Aug 15 2017 4:54 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Paul


Depends what you mean by shortest. I'd just use a bit of delphi and a loop eg - totally untested

var
datum: TDate;
DaysInYear:integer;
begin
datum := StrToDate('01/01/2016');
DaysInYear := 364; {365 for leap years}

for Cntr := 0 to DaysInYear do begin
datum := datum+ Cntr;
table.Insert;
table.fieldbyname('datefield').asdatetime := datum;
end;

Roy Lambert
Wed, Aug 16 2017 10:25 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Paul,

<< What is the shortest way to fill a table with records for each day of the year >>

Roy is correct, you'll want to just use a loop to do so.  I can't think of any way to do so using DBISAM's SQL capabilities without getting into temporary tables, etc.

Tim Young
Elevate Software
www.elevatesoft.com
Image