SQL Server查询采取10/27/2010 12:57:49 pm到12:57 pm格式 [英] SQL Server Query for take 10/27/2010 12:57:49 pm to 12:57 pm format

查看:80
本文介绍了SQL Server查询采取10/27/2010 12:57:49 pm到12:57 pm格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家都是Codeproject人....



我在SQL Server 2000中有一个datetime列,它给我这样的数据10/27/2010 12:57 :下午49点,我想查询这个专栏,就像下午12:57返回hh:mm pm一样。我用来获取此列的查询。我在C#windows应用程序中使用此查询。

解决方案

总结:

 SELECT 
CAST ('2003-10-03 15:15:59。0013621 +00:00'AS time(7))AS'time',
CAST('2003-10-03 15:15:59。0013621 + 00:00'AS日期)AS'日期',
CAST('2003-10-03 15:15:59.153'AS smalldatetime)AS
'sxxldatetime',
CAST('2003 -10-03 15:15:59.153'AS datetime)AS'datetime',
CAST('2003-10-03 15:15:59。0013621 +00:00'AS datetime2(7))AS
'datetime2',
CAST('2003-10-03 15:15:59.0013621 +00:00'AS datetimeoffset(7))AS
'datetimeoffset';



挑选六个合适的任何一个或多个。

时间日期smalldatetime datetime datetime2 datetimeoffset 
~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 〜
15:15:59.0013621 2003-10-03 2003-10-03 15:16:00 2003-10-03 15:15:59.153 2003-10-03 15:15:59.0013621 2003-10-03 15:15:59.0013621 +00:00


检查以下查询。转换功能将起作用



SELECT转换(varchar,date_column,114)
来自表的


< blockquote> ur,你可以尝试运行以下代码而不是通过转换。



 选择 count(*)来自 dbo.a 
其中 RcvDate> ' 2013-07-15 16:00:00.000' RcvDate< = ' 2013-07-16 16:00:00.000';


Hi all Codeproject guys....

I have a datetime column in SQL Server 2000 that gives me data like this 10/27/2010 12:57:49 pm and I want to query this column just have return hh:mm pm like 12:57 pm. Which query I use to fetch this column. I am using this query in C# windows application.

解决方案

In summary:

SELECT 
     CAST('2003-10-03 15:15:59. 0013621 +00:00' AS time(7)) AS 'time', 
      CAST('2003-10-03 15:15:59. 0013621 +00:00' AS date) AS 'date', 
       CAST('2003-10-03 15:15:59.153' AS smalldatetime) AS 
        'smalldatetime', 
         CAST('2003-10-03 15:15:59.153' AS datetime) AS 'datetime', 
          CAST('2003-10-03 15:15:59. 0013621 +00:00' AS datetime2(7)) AS 
        'datetime2',
           CAST('2003-10-03 15:15:59.0013621 +00:00' AS datetimeoffset(7)) AS 
        'datetimeoffset';


Pick any one, or more, of six suitable.

time date smalldatetime datetime datetime2 datetimeoffset
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15:15:59.0013621 2003-10-03 2003-10-03 15:16:00 2003-10-03 15:15:59.153 2003-10-03 15:15:59.0013621	2003-10-03 15:15:59.0013621 +00:00


Check below query. Convert function will do the trick

SELECT convert(varchar, date_column, 114)
from Table


ur,you can try to run the following codes not by convert .

select count(*) from dbo.a
where RcvDate > '2013-07-15 16:00:00.000' and RcvDate <='2013-07-16 16:00:00.000';


这篇关于SQL Server查询采取10/27/2010 12:57:49 pm到12:57 pm格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆