Solved

Calculate Current Month Name

Posted on 2002-04-27
3
202 Views
Last Modified: 2010-04-04
Hi all,

How can I calculate the month name from an integer?
I've seen a few examples of using DecodeDate, but none of them explain how to use it very well.

If the variable CurrentMonthAsInteger is equal to 1,
how do I get the CurrentMonthAsString (January), or whatever language I'm using? I don't want to use the constants Januery, February etc...

I want to use this to calculate the previous month.

Thanks,
Freerider.


 
0
Comment
Question by:Freerider
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 50 total points
ID: 6973348
Use FormatDateTime function:

  Example 1:
    Caption:= FormatDateTime('mmmm', Now);

  Example 2:
    Caption:= FormatDateTime('mmmm', EncodeDate(2002, 2, 1));
 
  Example 3:
    Caption:= FormatDateTime('mmmm', IncMonth(Date, -1)); // Get previous month


Motaz
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6973349
Also you can use LongMonthNames array to set your own months names:

  LongMonthNames[1]:= 'January';
  LongMonthNames[2]:= 'February';
etc.

Motaz

0
 

Author Comment

by:Freerider
ID: 6981660
Perfect.
Thanks Motaz - don't know why I haven't been able to find any simple examples like this before.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question