如何按月声明表格 [英] How do I declare the tables in monthlywise

查看:75
本文介绍了如何按月声明表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have start date and end date  and i want return the data by monthly wise if month is not finished then the data written by week wise for example Auguest 1st week 





我尝试过:





What I have tried:

SELECT * FROM table_name WHERE date_column between 'from date' AND 'to date'

推荐答案

确保使用表中的日期字段,请参阅: SQL Server和MySQL中的日期函数 [ ^ ]

有关使用日期函数的信息,请参阅:日期和时间数据类型和函数(Transact-SQL)| Microsoft Docs [ ^ ]

您可以使用 MONTH 功能,请参阅: MONTH(Transact-SQL)| Microsoft Docs [ ^ ]

要获得周数,您可以使用 DATEPART('ww',日期),请参阅: SQL Server DATEPART()函数 [ ^ ]
Make sure you use Date fields in your table, see: Date Functions in SQL Server and MySQL[^]
For working with Date functions, see: Date and Time Data Types and Functions (Transact-SQL) | Microsoft Docs[^]
You can use the MONTH function, see: MONTH (Transact-SQL) | Microsoft Docs[^]
To get the week number you can use DATEPART('ww', date), see: SQL Server DATEPART() Function[^]


这篇关于如何按月声明表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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