Solved

# Calculate Current Month Name

Posted on 2002-04-27
199 Views
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
Question by:Freerider
• 2

LVL 7

Accepted Solution

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

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

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

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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.