Information générale
Catégorie:
Codage, syntaxe et commandes
>>>>Is there a function to get the number of days in a month.
>>>>eg. the number of days in any month of any year.
>>>>
>>>>Thanks
>>>>Andrew
>>>
>>>Sometime ago I wrote a 10 line function to simply determine the last day of the current month. I kept adding days until the date function determined the data was invalid. Something like this:
>>>...
>>>For I = 1 to 31
>>> lcChkDate=Month...+"/"+STR(I,2)+"/"+Year...
>>> ...
>>> IF DATE(lcChkDate)=" / / "
>>> * Invalid Date take Previous I (Day) (I-1)
>>> * as last Day of Current Month
>>>
>>> * Define variable here ldDate=DATE(lcChkDate)
>>> EXIT
>>> ENDIF
>>>Endfor
>>
>>You may wanna take a look to one my FAQs in the KB. It can be done with a simple one line formula.
>>
>>Vlad
>Why don't you use
>day(gomonth(xdate ,1) - day(gomonth(xdate ,1))) && xdate is a date value
Why don't you read the whole thread? :) Just kidding. These threads on date formulas are quite funny and quite long. I think this is the 3rd or the 4th on this problem. And although a very good and simple solution (like yours) is given from the beggining, the thread continues for weeks. Of course, some of us forget about the thread, think that is a new one, etc and the same messages come over and over again. Also, it's interesting for me to see how somebody tries to argue that a 20 lines function is better than one line simple formula. Also, it's interesting to see how the wheel is reinvented everyday! :)
So, to resume these threads, there are 2 formulas for this problem. Yours and:
day( GoMonth(ldMyDate - Day(ldMyDate) + 1, 1) - 1)
I'm waiting for the 3rd one. :)
Vlad
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement