错误将字符串转换为DateTime

时间:2016-09-23 06:55:36

标签: sql-server sql-server-2008

q

输出:

SELECT CONVERT(datetime,'17/05/2015 22:15:00',103)

我想要包括2列是日期+时间

示例:Colunm日期和时间

2015-05-17 22:15:00.000

但错误查询

**Date**   **Time**

17/05/2015  22:15:00

从字符串转换日期和/或时间时转换失败。

2 个答案:

答案 0 :(得分:0)

只需将时间部分添加到日期部分:

SELECT DATEADD(ms, DATEDIFF(ms, '00:00:00', [Time]), CONVERT(DATETIME, [Date]))
FROM LPTables

这样可以精确到毫秒。

答案 1 :(得分:0)

只需用app.pdf.service: class: AppBundle\Service\PdfService arguments: ["a4", "landscape"] 封闭您的列。

<div data-sly-use.clientlibInclude="${'/libs/granite/sightly/templates/clientlib.html'}"></div>
<output data-sly-call="${clientlibInclude.css @ categories='angular-global-category'}" data-sly-unwrap />
<html> `enter code here`
<head>
    <title>Greeting Message using JavaScript</title> 
</head>

<body>  
<section class="intro">
 <h1> <label id="lblGreetings"></label></h1></section>
</body>
<script>

    var myDate = new Date();
    var hrs = myDate.getHours();

    var greet;

    if (hrs < 12)
        greet = 'Good Morning';
    else if (hrs >= 12 && hrs <= 17)
        greet = 'Good Afternoon';
    else if (hrs >= 17 && hrs <= 24)
        greet = 'Good Evening';


    document.getElementById('lblGreetings').innerHTML =
        '' + greet + ' Julio';

</script> 
</html>

示例:

enter image description here