Solved

Calculate Current Month Name

Posted on 2002-04-27
3
199 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now