Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

problem with monthly Reporting

Member Posts: 11
Hi !
I have this problem, I want develop a report passed on monthly but I have a problem how i can determine the ongoing month for eg. the date is 28-05-2006 to show in my report from the begining of the month eg. 01-05-2006 to the days date programatically. Please help!

• Member Posts: 6,349
: Hi !
: I have this problem, I want develop a report passed on monthly but I have a problem how i can determine the ongoing month for eg. the date is 28-05-2006 to show in my report from the begining of the month eg. 01-05-2006 to the days date programatically. Please help!
:
In Delphi dates (and times) are stored as numbers from a set 0-date. To get the difference between two dates, you can just subtract them. This will give you the number of days between them in the integer range, while the fractions represent the hours/minutes/seconds between them. Thus:
[code]
var
Date1, Date2: TDateTime;
begin
Date1 := EncodeDate(2006, 5, 1);
Date2 := Date;
Label1.Caption := FloatToStr(Date2-Date1);
end;
[/code]
shows the number of days between 1-5-2006 and today.
• Member Posts: 11
: : Hi !
: : I have this problem, I want develop a report passed on monthly but I have a problem how i can determine the ongoing month for eg. the date is 28-05-2006 to show in my report from the begining of the month eg. 01-05-2006 to the days date programatically. Please help!
: :
: In Delphi dates (and times) are stored as numbers from a set 0-date. To get the difference between two dates, you can just subtract them. This will give you the number of days between them in the integer range, while the fractions represent the hours/minutes/seconds between them. Thus:
: [code]
: var
: Date1, Date2: TDateTime;
: begin
: Date1 := EncodeDate(2006, 5, 1);
: Date2 := Date;
: Label1.Caption := FloatToStr(Date2-Date1);
: end;
: [/code]
: shows the number of days between 1-5-2006 and today.
:

Thanks ze
But as I see in the code shows only a one specific month proberly MAY month, but my problem is to show the ongoing month through out the year
Date1 := EncodeDate(2006, 5, 1) this will show in the begining of ONLY one month.
Thanks

• Member Posts: 6,349
: : : Hi !
: : : I have this problem, I want develop a report passed on monthly but I have a problem how i can determine the ongoing month for eg. the date is 28-05-2006 to show in my report from the begining of the month eg. 01-05-2006 to the days date programatically. Please help!
: : :
: : In Delphi dates (and times) are stored as numbers from a set 0-date. To get the difference between two dates, you can just subtract them. This will give you the number of days between them in the integer range, while the fractions represent the hours/minutes/seconds between them. Thus:
: : [code]
: : var
: : Date1, Date2: TDateTime;
: : begin
: : Date1 := EncodeDate(2006, 5, 1);
: : Date2 := Date;
: : Label1.Caption := FloatToStr(Date2-Date1);
: : end;
: : [/code]
: : shows the number of days between 1-5-2006 and today.
: :
:
: Thanks ze
: But as I see in the code shows only a one specific month proberly MAY month, but my problem is to show the ongoing month through out the year
: Date1 := EncodeDate(2006, 5, 1) this will show in the begining of ONLY one month.
: Thanks
:
:
Obviously the parameters to the EncodeDate() can be variables to be able to select different months. Here is another example:
[code]
Date2 := Date;
for i := 1 to 12 do
begin
Date1 := EncodeDate(2006, i, 1);