Solved

Calculate Current Month Name

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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