DateSerial(Year, Month + 1, 0)
Örnek:
Şubat 2013 tarihi için ayın son gününü bulmak : DateSerial(2013, 2 + 1, 0)
Fonksiyona, son gününün bulunması istenen yıl ve ay girildikten sonra Day parametresi olarakta 0 verilir. Bu parametreye 0 verildiği takdirde fonksiyon önceki ayın son gününü döndürür. Bu sebeptendir ki Month+1 ibaresi kullanılmıştır.
-------------------------------------------------------------------------------------------------------
Public Function DateSerial( _ ByVal [Year] As Integer, _ ByVal [Month] As Integer, _ ByVal [Day] As Integer _ ) As DateTime
Parameters
- Year
- Required. Integer expression from 1 through 9999. However, values below this range are also accepted. If Year is 0 through 99, it is interpreted as being between 1930 and 2029, as explained in the "Remarks" section below. If Year is less than 1, it is subtracted from the current year.
- Month
- Required. Integer expression from 1 through 12. However, values outside this range are also accepted. The value of Month is offset by 1 and applied to January of the calculated year. In other words, (Month - 1) is added to January. The year is recalculated if necessary. The following results illustrate this effect:
- If Month is 1, the result is January of the calculated year.
- If Month is 0, the result is December of the previous year.
- If Month is -1, the result is November of the previous year.
- If Month is 13, the result is January of the following year.
- Day
- Required. Integer expression from 1 through 31. However, values outside this range are also accepted. The value of Day is offset by 1 and applied to the first day of the calculated month. In other words, (Day - 1) is added to the first of the month. The month and year are recalculated if necessary. The following results illustrate this effect:
- If Day is 1, the result is the first day of the calculated month.
- If Day is 0, the result is the last day of the previous month.
- If Day is -1, the result is the penultimate day of the previous month.
- If Day is past the end of the current month, the result is the appropriate day of the following month. For example, if Month is 4 and Day is 31, the result is May 1.
No comments:
Post a Comment