如何按日期分组,不论时间如何 [英] How to group by date irrespective of time

查看:83
本文介绍了如何按日期分组,不论时间如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有一个有日期列的表。日期栏中的值与时间一致

即2008年2月1日下午12:00:00

2/1/2008 2:13:00 PM

2/3/2008 4:00:00 AM

3/1/2008 1:00:00 PM

3/1 / 2008 4:00:00

3/3/2008 2:18:00 AM

3/3/2008 5:00:00 PM

3/3/2008 7:08:12 PM


我想根据日期对数据进行分组,不论时间如何。我希望结果如下



日期计数

2/1/2008 2

2/3/2008 1

3/1/2008 2

3/3/2008 3


如何我使用T-SQL查询表以获得上述结果..我尝试使用不同的日期格式,但仍然没有得到预期的结果..

解决方案


您好,

我有一个有日期列的表。日期栏中的值与时间一致

即2008年2月1日下午12:00:00

2/1/2008 2:13:00 PM

2/3/2008 4:00:00 AM

3/1/2008 1:00:00 PM

3/1 / 2008 4:00:00

3/3/2008 2:18:00 AM

3/3/2008 5:00:00 PM

3/3/2008 7:08:12 PM


我想根据日期对数据进行分组,不论时间如何。我希望结果如下



日期计数

2/1/2008 2

2/3/2008 1

3/1/2008 2

3/3/2008 3


如何我使用T-SQL查询表以获得上述结果..我尝试使用不同的日期格式,但仍然没有得到预期的结果..



试试这个:

展开 | 选择 | Wrap | 行号


此查询在Oracle中有效,但我想在MS SQL中使用它。


你好,

我有一个有日期列的表。日期栏中的值与时间一致

即2008年2月1日下午12:00:00

2/1/2008 2:13:00 PM

2/3/2008 4:00:00 AM

3/1/2008 1:00:00 PM

3/1 / 2008 4:00:00

3/3/2008 2:18:00 AM

3/3/2008 5:00:00 PM

3/3/2008 7:08:12 PM


我想根据日期对数据进行分组,不论时间如何。我希望结果如下



日期计数

2/1/2008 2

2/3/2008 1

3/1/2008 2

3/3/2008 3


如何我使用T-SQL查询表格以获得上述结果..我尝试使用不同的日期格式,但我仍然没有得到预期的结果..



尝试:

展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


Hello,
I have a table which has a date column. The values in the date column are along with time
i.e., 2/1/2008 12:00:00 PM
2/1/2008 2:13:00 PM
2/3/2008 4:00:00 AM
3/1/2008 1:00:00 PM
3/1/2008 4:00:00 PM
3/3/2008 2:18:00 AM
3/3/2008 5:00:00 PM
3/3/2008 7:08:12 PM

I want to group the data based on dates irrespective of time. i,e., i want the results to be as follows


Date Count
2/1/2008 2
2/3/2008 1
3/1/2008 2
3/3/2008 3

How do i query the table using T-SQL to get the above reults..I tried using different date formats, but still i am not getting the expected results..

解决方案

Hello,
I have a table which has a date column. The values in the date column are along with time
i.e., 2/1/2008 12:00:00 PM
2/1/2008 2:13:00 PM
2/3/2008 4:00:00 AM
3/1/2008 1:00:00 PM
3/1/2008 4:00:00 PM
3/3/2008 2:18:00 AM
3/3/2008 5:00:00 PM
3/3/2008 7:08:12 PM

I want to group the data based on dates irrespective of time. i,e., i want the results to be as follows


Date Count
2/1/2008 2
2/3/2008 1
3/1/2008 2
3/3/2008 3

How do i query the table using T-SQL to get the above reults..I tried using different date formats, but still i am not getting the expected results..

Try this:

Expand|Select|Wrap|Line Numbers


This query works in Oracle, but i want it in MS SQL.


Hello,
I have a table which has a date column. The values in the date column are along with time
i.e., 2/1/2008 12:00:00 PM
2/1/2008 2:13:00 PM
2/3/2008 4:00:00 AM
3/1/2008 1:00:00 PM
3/1/2008 4:00:00 PM
3/3/2008 2:18:00 AM
3/3/2008 5:00:00 PM
3/3/2008 7:08:12 PM

I want to group the data based on dates irrespective of time. i,e., i want the results to be as follows


Date Count
2/1/2008 2
2/3/2008 1
3/1/2008 2
3/3/2008 3

How do i query the table using T-SQL to get the above reults..I tried using different date formats, but still i am not getting the expected results..


try:

Expand|Select|Wrap|Line Numbers


这篇关于如何按日期分组,不论时间如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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