Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cmonth
Message
From
03/10/2009 11:43:27
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
03/10/2009 10:09:43
Muthu Vel
Sty Company
India
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: Cmonth
Miscellaneous
Thread ID:
01427507
Message ID:
01427512
Views:
65
>In command window I have witten ?cmonth(date()) like this and enter return value in main vfp window current month name. example(october) but i want month and year for example(october 2009).
>
>How to do this?

There are several things you can do here. Tore gave you the specific reply, but you should also be aware of the following:
  • There are several functions that return different aspects of a date; this includes day(), month(), year() (day, month, and year), dow() (dow of week), and others.
  • When combining different pieces of data (in your example you wanted the month and the year), you usually convert everything to character data type. Since the year() will return a number, you convert it to text, with a function like transform(), str(), or padl().
  • If you need the same format over and over again, you may want to create a user-defined function for this.
  • If you want the month in another language, you may want to create a user-defined function for this. It is extremely simple; see sample code below.
    * Personal cmonth() function; easy to adapt, to show the month in a different language
    function mycmonth(tcDate)
    do case
    case month(tcDate) = 1
      return "January"
    case month(tcDate) = 2
      return "February"
    ...
    case month(tcDate) = 12
      return "December"
    otherwise && For example, empty or null date
      return "???"
    endcase
    Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
  • Previous
    Next
    Reply
    Map
    View

    Click here to load this message in the networking platform