是否有任何公式可以在Crystal报表vb.net中获取具有工作周数和一年的星期日日期?例如,我有
工作周#46和2012年..它应该显示2012年工作周46周日的日期(11,11,2012)
答案 0 :(得分:0)
没有任何默认函数可以获得,但我自己创建了一个函数来解决这个问题,如下所示:
Public Function W_SUNDAY(ByVal TWEEK As Byte, ByVal TYEAR As Integer)
Dim SRCDATE As Date = New Date(TYEAR, 1, 1) ' 1.1.2014 - BECAUSE BEGINING IS THE FIRST WEEK OF YEAR
For I = 1 To 12
For J = 1 To 31
Dim CTDATE As Date
Try ' TRAP ERRORS BECAUSE NOT ALL OF THE MONTHS HAS 31 DAYS :)
CTDATE = New Date(TYEAR, I, J)
Catch ex As Exception
End Try
If CTDATE.DayOfYear = 7 * (TWEEK - 1) Then
SRCDATE = CTDATE
Exit For
End If
Next
Next
If SRCDATE.DayOfWeek <> DayOfWeek.Sunday Then
For D = 1 To 6
SRCDATE = DateAdd("d", 1, SRCDATE)
If SRCDATE.DayOfWeek = DayOfWeek.Sunday Then
Exit For
End If
Next
End If
Return SRCDATE
End Function
让我知道这是否对你有帮助:) (抱歉我的英语不好)