Where can I post a submission for a Daily WTF?



  • I found this in our old ASP codebase:

     

     if (datepart("y", date)) < 0 then dateselect = "<OPTION value='/prog/schedule/week.asp?date=" &amp; CDATE(date) &amp; "'>This Week</OPTION><OPTION value='/prog/schedule/week.asp?date=" &amp; CDATE(date) + 7 - offset &amp; "'>" & CDATE(date) + 7 - offset & "</OPTION><OPTION value='/prog/schedule/week.asp?date=" &amp; CDATE(caldate) + 14 - offset &amp; "'>" & CDATE(date) + 14 - offset & "</OPTION>"

    else dateselect = "<OPTION value='" &amp; CDATE(date) - 7 - offset &amp; "'>" & CDATE(date) - 7 - offset & "</OPTION><OPTION value="/prog/schedule/week.asp">This Week</OPTION><OPTION value='/prog/schedule/week.asp?date=" &amp; CDATE(date) + 7 - offset &amp; "'>" & CDATE(date) + 7 - offset & "</OPTION><OPTION value='/prog/schedule/week.asp?date=" &amp; CDATE(date) + 14 - offset &amp; "'>" & CDATE(date) + 14 - offset & "</OPTION>" end if

     

    We were trying to get our graphic designer to learn some code and maintain the codebase. The question is "When is the year component of the date ever going to be < 0"?

    N



  • I know this pattern.  date is a string concatenation of three droplist values.  The default value on each droplist is probably "-1", so your designer thought he could use datepart on the string.  Does the code actually run?


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.