pillmill
asked on
asp: label.text to week of year?
I need to get the week of year into SQL.
Everything I have tried generates runtime or compile errors.
How can I do this:
I have asp:
Label2.Text = string of a date of the year
SQL: " ... DATEPART(wk, CONVERT(datetime,@Label,10 1) ) "
<SelectParameters>
<asp:ControlParameter Name="Label" ControlID="Label2" PropertyName="Text" />
</SelectParameters>
Everything I have tried generates runtime or compile errors.
How can I do this:
I have asp:
Label2.Text = string of a date of the year
SQL: " ... DATEPART(wk, CONVERT(datetime,@Label,10
<SelectParameters>
<asp:ControlParameter Name="Label" ControlID="Label2" PropertyName="Text" />
</SelectParameters>
use this
Dim weekNum As Integer = DatePart(DateInterval.Week OfYear, Date.Now, Microsoft.VisualBasic.Firs tDayOfWeek .Monday)
Dim weekNum As Integer = DatePart(DateInterval.Week
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DECLARE @date datetime
SET @date = '20090301'
SELECT CASE WHEN @date NOT BETWEEN DATEADD(day, -DATEPART(dw, (DATEADD(year, DATEDIFF(year, 0, @date) +1, 0))), (DATEADD(year, DATEDIFF(year, 0, @date) +1, 0))) +1 AND DATEADD(year, DATEDIFF(year, 0, @date) +1, 0) -1 THEN DATENAME(week, @date)
ELSE 1 END
Lior