Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining the End of the Month
Message
 
 
À
18/03/1999 09:36:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00199069
Message ID:
00199896
Vues:
20
Tom, just to add some detail to what Eric and Vlad have pointed out, your function depends on a SET DATE in MM/DD/YY format, and so will fail for any SET DATE that does not put the month first. Specifically, it will return erroneous results for any SET DATE which puts the day first (BRITISH/FRENCH, GERMAN, ITALIAN, DMY) and will return an empty date for any SET DATE which puts the year first (ANSI, JAPAN, TAIWAN, YMD). While this may not be an issue for your apps, it's still something to be cognizant of.

IMHO you'd be better off to use a method (such as the one suggested by Ed Rauh and others in this thread) that works for all SET DATE's and does not depend on SET CENTURY either. I do it like this:
*---------------------
FUNCTION LastOfMonth()
*---------------------
lparameters tdDate
if pcount() = 0 or type('tdDate') != 'D'
   RETURN {}
endif
RETURN GOMONTH( tdDate - DAY( tdDate) + 1, 1) - 1
ENDFUNC && LastOfMonth()
HTH,
Rick


>Hi Fida, try this.
>
>****************************************************
> * This function returns the last day of the month.
> * If Passed a value for mthno, returns the last day
> * of the month, n months from the date sent.
> * IF nodate passed, returns the current month-end date.
>*****************************************************
>PARAMETER datesent, mthno
>
>datesent =IIF(TYPE('datesent') <>"D", DATE(), datesent)
>mthno = IIF(TYPE('mthno') <>'N', 0, INT(mthno))
>
>IF mthno <> 0
> datesent =GOMONTH(datesent, mthno)
>ENDIF
>
>** Return last day of the month
>RETURN (GOMONTH(CTOD(ALLTRIM(STR(MONTH(datesent)))+ ;
> "/01/"+RIGHT(ALLTRIM(STR(YEAR(datesent))),2)), 1) -1)
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform