|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
... |
|||
:
Нравится:
Не нравится:
|
|||
16.09.2003, 14:28 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
Как в общем случае в VBA получить даты начала и конца интервалов (месяца, недели) ? ... |
|||
:
Нравится:
Не нравится:
|
|||
16.09.2003, 14:43 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
Немного из FAQ Наверное тебе это поможет: DatePart Function Returns a Variant (Integer) containing the specified part of a given date. Syntax DatePart(interval, date[,firstdayofweek[, firstweekofyear]]) The DatePart function syntax has these named arguments: Part Description interval Required. String expression that is the interval of time you want to return. date Required. Variant (Date) value that you want to evaluate. firstdayofweek Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed. firstweekofyear Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs. Settings The interval argument has these settings: Setting Description yyyy Year q Quarter m Month y Day of year d Day w Weekday ww Week h Hour n Minute s Second The firstdayofweek argument has these settings: Constant Value Description vbUseSystem 0 Use the NLS API setting. vbSunday 1 Sunday (default) vbMonday 2 Monday vbTuesday 3 Tuesday vbWednesday 4 Wednesday vbThursday 5 Thursday vbFriday 6 Friday vbSaturday 7 Saturday The firstweekofyear argument has these settings: Constant Value Description vbUseSystem 0 Use the NLS API setting. vbFirstJan1 1 Start with week in which January 1 occurs (default). vbFirstFourDays 2 Start with the first week that has at least four days in the new year. vbFirstFullWeek 3 Start with first full week of the year. Remarks You can use the DatePart function to evaluate a date and return a specific interval of time. For example, you might use DatePart to calculate the day of the week or the current hour. The firstdayofweek argument affects calculations that use the "w" and "ww" interval symbols. If date is a date literal, the specified year becomes a permanent part of that date. However, if date is enclosed in double quotation marks (" "), and you omit the year, the current year is inserted in your code each time the date expression is evaluated. This makes it possible to write code that can be used in different years. Note For date, if the Calendar property setting is Gregorian, the supplied date must be Gregorian. If the calendar is Hijri, the supplied date must be Hijri. The returned date part is in the time period units of the current Arabic calendar. For example, if the current calendar is Hijri and the date part to be returned is the year, the year value is a Hijri year. mahoune ... |
|||
:
Нравится:
Не нравится:
|
|||
16.09.2003, 14:59 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
К дате с первым днем месяца добавляешь 1 месяц и определяешь разницу в днях между этими датами. Всё решается ф-иями DateAdd(), DateDiff() ... |
|||
:
Нравится:
Не нравится:
|
|||
16.09.2003, 15:05 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
или так: берешь первое число следующего месяца и от этой даты отнимаешь один день, узнаешь номер дня - это и будет количество дней. Код: plaintext 1. 2.
IMHO, tpg предложил более простой вариант: Код: plaintext 1. 2.
... |
|||
:
Нравится:
Не нравится:
|
|||
16.09.2003, 18:23 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
можно и так :) ' Функция (MLD == Month Last Day) вычисляет последний день заданного месяца ' Год также по идее нужно передавать, т.к. февраль может быть 28 или 29 дней Public Function MLD(intМесяц As Integer, Optional intГод As Integer) As Integer On Error GoTo Err_MLD If IsMissing(intГод) Then MLD = Day(DateSerial(Year(Date), intМесяц + 1, 0)) Else MLD = Day(DateSerial(intГод, intМесяц + 1, 0)) End If Exit Function Err_MLD: Resume Next MLD = 0 End Function ... |
|||
:
Нравится:
Не нравится:
|
|||
16.09.2003, 19:48 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
Может кому пригодиться. По названию месяца получить его начало и конец. то есть зная "февраль" текущего года получаем "01.02.2008-29.02.2008" Dim m As String 'название месяца Dim f As String Dim date_from As String Dim date_to As String m = "январь" f = "01 " & m & " " & Year(Date) If IsDate(f) Then date_from = "01." & Format(f, "mm") & "." & Year(Date) date_to = DaysOfMonth2(CDate(f)) & "." & Format(f, "mm") & "." & Year(Date) MsgBox date_from & vbCrLf & date_to Else MsgBox "error" End If ... |
|||
:
Нравится:
Не нравится:
|
|||
18.03.2008, 00:15 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
Нарыл кусок кода в архиве где трахался примерно с такой же проблемой, может нароешь для себя чего-нибудь ;-): Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52.
... |
|||
:
Нравится:
Не нравится:
|
|||
19.03.2008, 14:15 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
Поискать не судьба? > Автор: Worobjoff > Дата начала периода: > DateSerial(Год, Месяц, 1) > > Дата конца периода: > DateAdd("d", -1, DateAdd("m", 1, DateSerial(Год, Месяц, 1))) Вторая часть и будет искомая величина ;) Posted via ActualForum NNTP Server 1.4 ... |
|||
:
Нравится:
Не нравится:
|
|||
19.03.2008, 14:28 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
Day(DateAdd("d", -1, DateAdd("m", 1, [твоя дата]))) ... |
|||
:
Нравится:
Не нравится:
|
|||
20.03.2008, 07:29 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
detail, спасибо! Очень пригодилось, до этого пользовался не удобным и громоздким кодом. Спс! ... |
|||
:
Нравится:
Не нравится:
|
|||
17.03.2014, 00:18 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
detailDay(DateAdd("d", -1, DateAdd("m", 1, [твоя дата]))) и что Код: vbnet 1. 2. 3. 4.
единица в мессаге значит? ... |
|||
:
Нравится:
Не нравится:
|
|||
02.04.2014, 20:46 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
катастрофаdetailDay(DateAdd("d", -1, DateAdd("m", 1, [твоя дата]))) и что Код: vbnet 1. 2. 3. 4.
единица в мессаге значит? d = #1/2/2014# - 2 января 2014. ... |
|||
:
Нравится:
Не нравится:
|
|||
02.04.2014, 22:59 |
|
Как узнать количество дней в месяце ?
|
|||
---|---|---|---|
#18+
Function DaysOfMonth(Optional iMonth As Integer = 0, Optional iYear As Integer = 0, Optional dDate As Date = #1/1/1900#) As Integer If iMonth <> 0 And iYear <> 0 Then DaysOfMonth = Day(DateAdd("d", -1, DateAdd("m", 1, DateSerial(iYear, iMonth, 1)))) ElseIf dDate > #1/1/1900# Then DaysOfMonth = DateDiff("d", dDate, DateAdd("m", 1, dDate)) Else DaysOfMonth = 0 End If End Function Гибрид ... |
|||
:
Нравится:
Не нравится:
|
|||
18.04.2016, 09:02 |
|
|
start [/forum/topic.php?fid=60&gotonew=1&tid=2155562]: |
0ms |
get settings: |
11ms |
get forum list: |
14ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
135ms |
get topic data: |
11ms |
get first new msg: |
7ms |
get forum data: |
2ms |
get page messages: |
52ms |
get tp. blocked users: |
2ms |
others: | 306ms |
total: | 546ms |
0 / 0 |