This is a little tricky since Sybase doesn't do this. All Sybase does is tell you the week of the year. Here's what I came up with:
select datepart(wk,'12/12/2003') - datepart(wk,dateadd(dd, -(datepart(dd,'12/12/2003') - 1), '12/12/2003')) + 1
Subtract the week of the date you supplied from the week where the 1st of the month falls and add 1. This assumes that you're talking about the calendar week of the month (ex: the 1st fell on a Monday this month so the first week was the 1st thru the 6th and the 7th would be in the second week).
Originally posted by joesach
I dont know Sybase much. Could someone pls help me with this query.?
input : a date ( Eg. 12.12.2003)
output : which week that date is of that month ?
( 1st , 2nd, 3rd , 4th or 5th ?)