Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Lowdown on Julian date
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00188463
Message ID:
00188622
Vues:
22
>Rich,
>
>You can get rid of the loop if you simply subtract Jan 1 from the date and add 1. Subtrarcting two dates will give you the number of days difference.
>
>>The Julian daynumber (I think) is the type of number you were expecting with year plus days-in-year, e.g. - 1999048 for today. I don't think there's a function to return this number within native VFP commands and functions, but it'd be awfully easy to write. Something like:
>>
FUNCTION JulDayNum
>>LPARAMETER ldDate
>>LOCAL lnRetVal, lnMonthNum
>>IF TYPE(ldDate) != 'D'	&& May also want to accept D/T
>>	RETURN 0	&& zero
>>ENDIF
>>lnRetVal = YEAR(m.ldDate)*1000
>>FOR lnMonthNum = 1 TO MONTH(m.ldDate) - 1
>>	* Add number of days for each month from an array
>>ENDFOR
>>lnRetVal = m.lnRetVal + DAY(m.ldDate)
>>RETURN m.lnRetVal
I knew there was a simpler way, but I couldn't think of it off the top of my head. I've often used Date - DAY(Date) + 1 to get the first of a month. I know how date math works, pretty much. Just had a little brain lapse there.

Thanks, David!
Rich Addison, Micro Vane, Inc., Kalamazoo, MI
Relax, don't worry, have a homebrew.
- Charlie Papazian, The New Complete Joy of Home Brewing
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform