[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

Calculate Current Month Name

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
Freerider
Asked:
Freerider
  • 2
1 Solution
 
MotazCommented:
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
 
MotazCommented:
Also you can use LongMonthNames array to set your own months names:

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

Motaz

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now