Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Know if a date is end of month Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
02-Nov-02
Category
Algorithm
Language
Delphi 2.x
Views
89
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Radikal Q3

Kwow if a date is end of month

Answer:

It's to say: know if a date is the last day of its month.
1   
2   procedure TForm1.Button1Click(Sender: TObject);
3    
4     {Devuelve TRUE si la fecha dada es el ultimo dia del mes
5     Returns TRUE if the date is the last day of the month}
6     function IsMonthEnd( const Day: TDateTime ): boolean;
7     var 
8       Nada, ElDia: word;
9     begin 
10      {Hallamos el dia del mes de la fecha +1}
11      {Day of month of date+1}
12      DecodeDate ( Day+ 1, Nada, Nada, ElDia );
13      {Si es 1, entonces es fin de mes}
14      {If is 1 then is end of month}
15      Result:=( ElDia=1 );
16    end; 
17   
18  begin 
19    {Ejemplo de llamada:}
20    {A call Example:}
21    if IsMonthEnd(Now) then ShowMessage( 'Hoy es fin de mes!+
22         #10+
23                                         '
24  end; 

 
The operation is as simple as to make a DecodeDate of the date + 1, this way we 
will obtain the following day to which we are inspecting; if it is day 1... it 
means that the day in question is month end. 
Let us don't forget that the format TDateTime that Delphi uses uses the whole part to score the days lapsed from 12/30/1899, so if we added him a 1to the date... we will obtain the following day.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC