title: TimeValue is not a recognized built-in function name
body: <p>I need help adjusting the query below to work under ms sql. I migrating Access Databases to SQL Server and the query below is falling. </p>
  
  <p>I am getting the following  error: </p>
  
  <p>"Error Executing Database Query.[Macromedia][SQLServer JDBC Driver][SQLServer]'TimeValue' is not a recognized built-in function name."</p>
  
  <p>Thank you in advance.</p>
  
  <hr>
  
  <pre><code>SELECT  M.MessageID, M.Subject, M.ShortDesc, M.subName, M.Submitter, C.CategoryName,
          DateValue( 
              IIF ( 
                  DatePart( 'w', IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow)) ) = 1, 
                  DateAdd( 'd', 1, IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow)) ), 
                  IIF(
                      DatePart( 'w', IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow)) ) = 7, 
                      DateAdd( 'd', 2, IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow)) ),
                      IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow))
                  ),
              )
          ) AS DateToShow
  FROM    MessageInfo M, Categories C
  WHERE   M.Approved = true 
      AND C.CategoryID = M.Category 
              ORDER BY C.CategoryPreference, C.CategoryName, 
      DateValue( 
          IIF ( 
              DatePart( 'w', IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow)) ) = 1, 
              DateAdd( 'd', 1, IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow)) ), 
              IIF(
                  DatePart( 'w', IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow)) ) = 7, 
                  DateAdd( 'd', 2, IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow)) ),
                  IIF(TimeValue(M.DateToShow)&lt;='10:00',M.DateToShow,DateAdd('d',1,M.DateToShow))
              ),
          )
      )
      DESC, M.Subject
  </code></pre>