从表中获取在日期字段中具有搜索月份的所有条目 [英] Get all entries from a table which have the searched month in a date field

查看:58
本文介绍了从表中获取在日期字段中具有搜索月份的所有条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 3 个字段的表:IDstartdatestopdate.

I have a table that has 3 fields: ID, startdate, stopdate.

它们的类型为日期".

如何选择给定月份中具有 startdate 的所有条目?

How can I select all entries which have the startdate in a given month?

例如:显示 startdate 在08"月份的所有条目.

For example: Show me all entries where the startdate is in the month "08".

这可能吗?

推荐答案

SELECT *
FROM tblName
WHERE MONTH(startdate) = 8

<小时>

逐行拆分:


Line by line break-up:

  1. SELECT * => 选择所有列
  2. FROM tblName => 应从 tblName 表中获取行.
  3. WHERE MONTH(startdate) = 8 => startdate08 月.
  1. SELECT * => selects all columns
  2. FROM tblName => the rows should be fetched from tblName table.
  3. WHERE MONTH(startdate) = 8 => the startdate is in the month 08.

这篇关于从表中获取在日期字段中具有搜索月份的所有条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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