Link to home
Start Free TrialLog in
Avatar of pillmill
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,101) ) "

<SelectParameters>
               <asp:ControlParameter Name="Label"  ControlID="Label2"  PropertyName="Text" />
               </SelectParameters>
Avatar of liorfr
liorfr
Flag of Israel image

This one works:
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
use this

Dim weekNum As Integer = DatePart(DateInterval.WeekOfYear, Date.Now, Microsoft.VisualBasic.FirstDayOfWeek.Monday)
ASKER CERTIFIED SOLUTION
Avatar of havj123
havj123
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial