如何检索3月出生的所有男性记录 [英] How to retrieve all male records born in march

查看:68
本文介绍了如何检索3月出生的所有男性记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的sql数据库中检索出生在3月份的所有男性记录。日期

数据保存如2000-03-11 00:00:00:00

我尝试使用此查询但它没有返回任何结果。请帮帮我



i am trying to retrieve all male records born in march from my sql database. the date
data is saved like 2000-03-11 00:00:00:00
i tried using this query but it returned no result. please help me out

SELECT FormattedMembershipid, Surname, Othername, REPLACE(CONVERT(NVARCHAR, Dateofbirth, 106), ' ', '-',) AS  Dateofbirth from tblPersonal WHERE Dateofbirth LIKE ' 0000-03-00' AND Gender = 'Male';

推荐答案

尝试..



try..

SELECT FormattedMembershipid, Surname, Othername, REPLACE(CONVERT(NVARCHAR, Dateofbirth, 106), ' ', '-',) AS Dateofbirth from tblPersonal WHERE month(Dateofbirth)=3 AND Gender = 'Male';





见..

http://www.w3schools.com/sql/func_datepart.asp [ ^ ]


我当然希望您将日期存储为日期而非字符串。



如果这是SQL Server,请查看DATEPART功能。



http:// msdn。 microsoft.com/en-us/library/ms174420.aspx [ ^ ]
I certainly hope you are storing dates as dates and not as strings.

If this is SQL Server, look into the DATEPART function.

http://msdn.microsoft.com/en-us/library/ms174420.aspx[^]


这篇关于如何检索3月出生的所有男性记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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