Re: DATETIME YEAR TO WEEK .....
Posted in 1999
Neil Truby wrote: > > You can do this in Sybase, but I can't find any equivalent functionality in > Informix (obviously, it returns a week number in the range 1-53). > > Does anyone know if it can be done? Got to do it yourself: # Set up a days-in-month array with Jan. = 0, Dec. = 335(or 336), # handling leap years, then: # LET Month = month( somedate ) LET MDay = day( somedate ) LET WDay = weekday( somedate ) LET Week = (days_in_month( Month ) + MDay + 6) / 7 # This is linear weeks, so: # If you want to count the week starting Sunday before New Years as # week 1 Add this adjustment: # IF (WDay >= weekday( extend( mdy( 1, 1, year( someday ) ) ) THEN # LET Week = Week + 1 # END IF # Subtract one instead if you want to start week 1 with the Sunday # after New Years. # Make a stored procedure and voila! Art S. Kagel