The datepart hour is not supported by date function dateadd for data type date

前端 未结 2 1017
傲寒
傲寒 2021-02-13 04:37

While I am running the following query in jasper reports, I got the exception. \"net.sf.jasperreports.engine.JRException: Error executing SQL statement for : Activity_Summary\".

2条回答
  •  故里飘歌
    2021-02-13 05:34

    To avoid the error message "The datepart hour is not supported by date function dateadd for data type date" it's sometimes necessary to do a double cast after getting the current time (firstly to cast it as date to get rid of the time, and then back to datetime to enable adding time to it). For example, if you need 11:00 today, use:

    DATEADD(hour, 11, cast(cast(getdate() as date) as datetime))
    

提交回复
热议问题