每个人,
我有一个问题困扰了我一天,无法弄清楚。我正在寻找的是SSRS Expression中的公式,它将告诉我当年第一个ISO周的第一天是什么日期。
例如:
我会感激任何帮助吗? 谢谢,
答案 0 :(得分:2)
您可以使用此功能:
Public Function dtFirstDayOfISOYear(ByVal intYear As Integer) as Datetime
'the first week of a ISO year is the week that contains the first Thursday of the year (and, hence, 4 January)
Dim intDayOfWeek As Integer = CInt(New DateTime(intYear, 1, 4).DayOfWeek)
'ISO weeks start with Monday
If intDayOfWeek < DayOfWeek.Monday Then intDayOfWeek = intDayOfWeek + 7
Return DateAdd(DateInterval.Day, -intDayOfWeek + 1, New DateTime(intYear, 1, 4))
End Function
使用像这样的表达式来调用它:
=Code.dtFirstDayOfISOYear(2014)
您还可以使用这样的独立表达式:
=DateAdd("d", (-1) * (CInt(New DateTime(2014, 1, 4).DayOfWeek) + IIf(CInt(New DateTime(2014, 1, 4).DayOfWeek) < DayOfWeek.Monday, 7, 0)) + 1, New DateTime(2014, 1, 4))