Customized function related to the ASP and week

xiaoxiao2021-03-06  40

Recently, there is a computational week's needs, watching the online ready-made code, not very suitable, I have to do it.

The first week of the year is the first week of the first week by default.

'Calculate the first week of the first week

Function firstday (Inputyear)

For i = cdate (Inputyear & "- 1-1") To CDATE (Inputyear & "- 1-7)

IF weekday (i) = 2 THEN

Firstday = i

EXIT for

END IF

NEXT

END FUNCTION

'The calculation input date is the function of the next few weeks

Function CalcWeekno (Inputdate)

Toyear = Year (InputDate)

Fday = firstday (Toyear)

IF Datediff ("D", FDAY, INPUTDATE <0 THEN

FDAY = firstday (Toyear-1)

END IF

'CalcWeekno = fday

Daynum = datediff ("D", fday, inputdate)

Calcweekno = int (daynum / 7) 1

END FUNCTION

'According to the number of weeks and years, calculate the first day of the week.

Function Getfst (Inputyear, Weekno)

FDAY = firstday (Inputyear)

Getfst = dateadd ("D", (Weekno-1) * 7, FDAY

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-62470.html

New Post(0)