C# DatePart() ?
- From: Mika M <mahmik_removethis@xxxxxxxxxx>
- Date: Tue, 05 Jun 2007 10:37:50 +0300
Hi!
I'm converting some methods of VB-class into C#-class for another project. It's quite easy, but when converting method which returns last week number of the entered year I got problems. The VB code is...
Private Function GetLastWeek(ByVal year As Integer) As Integer
'// Get last day of the year
Dim dte As DateTime = New DateTime(year, 12, 31)
'// Return last day weeknumber of the year
Return dte.Year * 100 + DatePart(DateInterval.WeekOfYear, dte, FirstDayOfWeek.Monday, FirstWeekOfYear.System)
End Function
How to do this using C# because the following code below is not working because "DatePart" is not available in C#?
private int GetLastWeek(int year)
{
// Get last day of the year
DateTime d = new DateTime(year, 12, 31);
// Return last day weeknumber of the year
return d.Year * 100 + DatePart(DateInterval.WeekOfYear, d, FirstDayOfWeek.Monday, FirstWeekOfYear.System);
}
--
Thanks in advance!
Mika
.
- Follow-Ups:
- Re: C# DatePart() ?
- From: Mika M
- Re: C# DatePart() ?
- From: Nicholas Paldino [.NET/C# MVP]
- Re: C# DatePart() ?
- From: Peter Duniho
- Re: C# DatePart() ?
- Prev by Date: Undocument 'feature' of PixelOffsetMode.Half :))
- Next by Date: Re: Splitting a string with Regex and keep the separator
- Previous by thread: Undocument 'feature' of PixelOffsetMode.Half :))
- Next by thread: Re: C# DatePart() ?
- Index(es):