Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Calculate Current Month Name

Posted on 2002-04-27
3
Medium Priority
?
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Motaz earned 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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