Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting weird date format
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00048265
Message ID:
00048476
Vues:
21
>I am writing a utility to slice and dice a data file imported from another application and appending it to a VFP table for report running and queries.
>
>One section of the data contains the date in the following format YYYDDD where YYY is the year (097) and DDD is the day number of the current year (245). I'm quite familiar with VFP's date functions and have converted form a number of formats in the past, but this one has me stumped. Unless I have completely missed it, I don't know of a "day of year" function in VFP.
>
>Has anyone come accross this type of date format before and more importantly, has anyone written a utility to convert this six character slice of data into a date?
>
>Thanks, AL
Al,

Here's a small code segment that will convert this data to a VFP date;

PROCEDURE ConvDate
LPARAMETERS pcDate

LOCAL ldDate, lcYear, lcOldDateSet, lnDays
lcOldDateSet = SET("DATE")
SET DATE AMERICAN
ldDate = CTOD("01/01/"+ STR(1900 + STR(LEFT(pcDate,3),4,0) )
lnDays = VAL(RIGHT(pcDate,3),3,0)
RETURN ldDate + lnDays - 1
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform