Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cmonth
Message
De
03/10/2009 21:16:56
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
03/10/2009 12:31:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Cmonth
Divers
Thread ID:
01427507
Message ID:
01427543
Vues:
67
>>>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
    >>
    >
    I didn't try it, but I suspect that would get the month in the language in which Windows is installed. Is that correct?

    My specific needs were to print the month in Spanish, no matter what the language of the OS or of Visual FoxPro. Of course, for distributing an application to different countries, getting the month names from the operating system seems more flexible.
    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)
  • Précédent
    Suivant
    Répondre
    Fil
    Voir

    Click here to load this message in the networking platform