Например: номер недели 11, получаем от 12 марта до 18.
Номер недели получаю так:
- Код: Выделить всё
numberWeek = DatePart( "Ww", Date, vbMonday, vbFirstFourDays)
А вот в какую строну капать на счет поставленной задачи не знаю
numberWeek = DatePart( "Ww", Date, vbMonday, vbFirstFourDays)
Alibek писал(а):Date - Weekday
Sirik писал(а):интерфейс такого типа: Номер недели -> Интервал: 11 -> 12.03.12 - 18.03.12
Public Sub Try()
Dim numberWeek_FirstFourDays As Variant, numberWeek_FirstJan1 As Variant
Dim theDay1 As Variant, theDay2 As Variant
Dim D As Date
Dim firstDate As Date, lastDate As Date
Debug.Print "numberWeek_FirstJan1 numberWeek_FirstFourDays theDay1 theDay2"
D = Date
numberWeek_FirstJan1 = DatePart("Ww", D, vbMonday, vbFirstJan1)
numberWeek_FirstFourDays = DatePart("Ww", D, vbMonday, vbFirstFourDays)
theDay1 = DatePart("d", D, vbMonday, vbFirstJan1)
theDay2 = DatePart("d", D, vbMonday, vbFirstFourDays)
Debug.Print D, numberWeek_FirstJan1, numberWeek_FirstFourDays, theDay1, theDay2
D = DateSerial(2011, 1, 1)
numberWeek_FirstJan1 = DatePart("Ww", D, vbMonday, vbFirstJan1)
numberWeek_FirstFourDays = DatePart("Ww", D, vbMonday, vbFirstFourDays)
theDay1 = DatePart("d", D, vbMonday, vbFirstJan1)
theDay2 = DatePart("d", D, vbMonday, vbFirstFourDays)
Debug.Print D, numberWeek_FirstJan1, numberWeek_FirstFourDays, theDay1, theDay2
Debug.Print
firstDate = Date - Weekday(Date, vbMonday) + 1
lastDate = firstDate + 6
Debug.Print firstDate; Format(firstDate, "dddd, mmm d yyyy", vbMonday, vbFirstFourDays)
Debug.Print lastDate; Format(lastDate, "dddd, mmm d yyyy", vbMonday, vbFirstFourDays)
End Sub
Сейчас этот форум просматривают: AhrefsBot, Google-бот и гости: 62