Important alert: (current site time 7/16/2013 5:08:56 AM EDT)
 

article

Get the name of the day today!

Email
Submitted on: 7/14/2003 7:32:38 AM
By: Christer Bru 
Level: Beginner
User Rating: By 4 Users
Compatibility: Delphi 7, Delphi 6, Delphi 5, Delphi 4, Pre Delphi 4
Views: 8100
 
     Easy-to-understand-function that returns the day todays name in string and takes no parameters. It returns the name in Englsih even if the operating system is another laguage. Good for text editing programs. Please rate...

 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				Here is an example of what the function returns: 
'The day today is ' + daytoday+'.'
Returns on a monday:
The day today is Monday.

Here is the function:
function daytoday: string;
begin
Result:=''; {Can be removed}
if dayofweek(now)=1 then
result:='Sunday' else
if dayofweek(now)=2 then
result:='Monday' else
if dayofweek(now)=3 then
result:='Tuesday' else
if dayofweek(now)=4 then
result:='Wednesday' else
if dayofweek(now)=5 then
result:='Thursday' else
if dayofweek(now)=6 then
result:='Friday' else
if dayofweek(now)=7 then
result:='Saturday';
end;


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

7/18/2003 4:57:59 AM

only this , not bad
(If this comment was disrespectful, please report it.)

 
8/6/2003 9:31:45 AM

you should simply put the days in an array,
then return array[ Dayofweek(Now) ].

This eliminates having to go through 7 if statements.


(If this comment was disrespectful, please report it.)

 
8/6/2003 10:05:11 AMSergey Gurevich

I understand that this code for beginners. You can use case insted of
"if" statment...it faster. But did you
ever think about that this function read
computer date/time ... what if computer time settings incorrect?
It is a subject to think about.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.