如何从年份中选择数据 [英] how to select data from year
本文介绍了如何从年份中选择数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
select * from table其中createddate = @ year
如何获取上述sql查询
解决方案
< blockquote>
如果你只想使用年份那么你可以使用
选择 * 来自 table 其中 createddate = YEAR( @ YourDate )
@year
是一个参数。
因此在Sql Server中执行之前,应该用适当的值替换它。
string Year = ddlYear.SelectedItem.Text;
DateTime Fdate = Convert.ToDateTime(年+ - + 01 + - + 01 跨度>);
DateTime Tdate = Convert.ToDateTime(年+ - + 12 + - + 12 跨度>);
select * from table where createddate=@year
how to fetch the above sql query
解决方案
Hi,
If you want to use only year then you can use
select * from table where createddate = YEAR (@YourDate)
@year
is a parameter.
So this should be replaced with the appropriate value before being executed in Sql Server.
string Year = ddlYear.SelectedItem.Text; DateTime Fdate = Convert.ToDateTime(Year + "-" + 01 + "-" + 01); DateTime Tdate = Convert.ToDateTime(Year + "-" + 12 + "-" + 12);
这篇关于如何从年份中选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文