In my sql database there is a column dateofbirth which contains the birthdate of my customers with this form: 31/12/2016 Column type is varchar(50).
I need to select the customers which 'day' and 'month' is like datetime.now Here is my code:
select name,mobile from memberform where dateofbirth like '" + DateTime.Now.ToString("d/M") + "%'
The code works. But Today in 1-1-2017 i observed that it selects also customers where birthday is 1-10-xxxx.Why happen this?
通配符%
将匹配任何字符偶数,请尝试更新代码以在其后添加另一个/
,如下所示:
'" + DateTime.Now.ToString("d/M") + "/%'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.