Last post Dec 21, 2011 09:58 AM by rajsedhain
Dec 20, 2011 10:30 PM|esims|LINK
I had some trouble specifying Monday as the first day of week in the DateDiff function.
The following syntax does not work:
Dim myWeekNumber as Int32 = DateDiff("ww",date1,date2,2)
Compiler Error Message: BC30519: Overload resolution failed because no accessible 'DateDiff' can be called without a narrowing conversion
However, using the enumeration value (FirstDayOfWeek.Monday) instead of the value (2) does work. I wonder why.
Dec 21, 2011 04:24 AM|sendtosree|LINK
why don't u use some thing like this
Dim myWeekNumber As Int32 = DateDiff(DateInterval.WeekOfYear, date1, date2, FirstDayOfWeek.Monday)
Dec 21, 2011 09:58 AM|rajsedhain|LINK
you can do something like this:
DATEADD(week, DATEDIFF(day, 0, @StartDate)/7, 0)
test this :
SELECT DATEADD(week, DATEDIFF(day, 0, getdate())/7, 0)