Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert days into dd-mm-yy format
Message
De
11/07/2005 03:30:16
 
 
À
11/07/2005 03:18:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows '98
Network:
SAMBA Server
Database:
Visual FoxPro
Divers
Thread ID:
01031091
Message ID:
01031103
Vues:
15
04-09-00 not shows 4 days, 9 monts and 0 years it shows 04-Sep-2000.
If you to get how many years, month and days you have in that variable you must write your own function. Something like:
FUNCTION DaysToPeriod(lnDays)
  LOCAL lnYears, lnMnts
  lcRetVal = ""
  lnYears = INT(lnDays/365) && 365 days are assumed as year no metter if the year is leap or no.
  lnDays  = lnDays - lnYears*365
  lnMnts  = INT(lnDays/30)  && 30 days are assumed as month
  lnDays  = lnDays - lnMnts*30

RETURN STR(lnDays,2)+"-"+STR(lnMnts,2)+"-"+STR(lnYears,3)
>Dear Sir,
>
>Suppose I have a 100 days in a variable named day1
>When I apply your commands it shows 04-09-00
>it means 4 days 9 months and 0 year which incorrect
>
>The answre should be as
>10-03-00, it is ten days three months and zero year
>
>Please modify your codes
>
>
>LOCAL lcCentury, lcDate, lcMark
>*!* Save setting so we can put them back
>lcCentury = SET("Century")
>lcDate = SET("Date")
>lcMark = SET("Mark")
>
>CLEAR
>day1=100
>
>SET CENTURY OFF
>SET DATE YMD
>?{^1999-12-31} + day1
>
>SET CENTURY ON
>SET DATE MDY
>?{^1999-12-31} + day1
>
>SET CENTURY OFF
>SET DATE MDY
>?{^1999-12-31} + day1
>
>*!* This one give you what you wanted
>SET MARK TO "-"
>SET CENTURY OFF
>SET DATE MDY
>?{^1999-12-31} + day1
>
>SET CENTURY &lcCentury
>SET DATE &lcDate
>SET MARK TO (lcMark)
>
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform