string strDate =odate.sendForm.Value.ToString("yyyy-MM-dd 00:00:00", DateTimeFormatInfo.InvariantInfo).Trim();
string endDate = odate.sendTo.Value.ToString("yyyy-MM-dd 23:59:59", DateTimeFormatInfo.InvariantInfo).Trim();sendForm sendTo 这两个是日期控件的name值odate 定义日期控件的别名 日期控件我做成类了,方便调用!temp.orderdate这个事日期的字段我想问如何用if条件判断temp.orderdate取出的日期 在strDate 和 endDate 日期范围之间if(这里面怎么写?)
{
return true;
}
else
{
false;
}请指教!!!!!!!!!!
string endDate = odate.sendTo.Value.ToString("yyyy-MM-dd 23:59:59", DateTimeFormatInfo.InvariantInfo).Trim();sendForm sendTo 这两个是日期控件的name值odate 定义日期控件的别名 日期控件我做成类了,方便调用!temp.orderdate这个事日期的字段我想问如何用if条件判断temp.orderdate取出的日期 在strDate 和 endDate 日期范围之间if(这里面怎么写?)
{
return true;
}
else
{
false;
}请指教!!!!!!!!!!
解决方案 »
- C# 发布网站问题
- C#网上考试系统
- 希望得到准确的答案,clr提供的单例模式是否是线程安全的
- 如何解决远程SendKeys.SendWait问题,急急急..........
- 源代码中含有简繁体汉字说明或注释如何在英文环境中打开不会乱码?
- DrawImage出错,不知道哪里错了。
- C#中怎么把Combox中选中的数转换为整型数值?
- 这个可以实现吗?
- 如何点右键取选中树的一个结点
- 如何用C#与添加数据库的DateTime字段
- DateTime.AddDays的问题。不知是bug还是我没搞清楚。
- 用Forms based Authentification方式 如何连接Exchange server
DateTime t1,
DateTime t2
)参数t1
类型:System..::.DateTime
第一个 DateTime。t2
类型:System..::.DateTime
第二个 DateTime。返回值
类型:System..::.Int32
有符号数字,指示 t1 和 t2 的相对值。值类型
条件小于零
t1 早于 t2。零
t1 与 t2 相同。大于零
t1 晚于 t2。
DateTime a = new DateTime(2009, 9, 7);
DateTime b = new DateTime(2009, 9, 9);
DateTime c = new DateTime(2009, 9, 8);
private void button2_Click(object sender, EventArgs e)
{
if (DateTime.Compare(a,c)<0&&DateTime.Compare(b,c)>0)//c时间段在a时间和b时间段之间
{
MessageBox.Show("OK");
}
}
select count(*) from temp where temp.orderdate between '"+strDate+"' and '"+endDate+"' ;
if count(*)取得 =0 then
return false
else
return true
DateTime strDate =(DateTime)odate.sendForm.Value.ToString().Trim();
DateTime endDate = (DateTime)odate.sendTo.Value.ToString().Trim();temp.orderdate也为日期型if(temp.orderdate > strDate && temp.orderdate < endDate )
{}
引用 2 楼 yu7733 的回复:
引用 1 楼 liu_b 的回复:
使用 DateTime.Compare 不行哦
给你参考: C# codeDateTime a = new DateTime(2009, 9, 7);
DateTime b = new DateTime(2009, 9, 9);
DateTime c = new DateTime(2009, 9, 8);
private void button2_Click(object sender, EventArgs e)
{
if (DateTime.Compare(a,c)<0&&DateTime.Compare(b,c)>0)//c时间段…
[/Quote这个不是把日期也死了吗,不行吧
temp.orderdate取出的日期 在strDate 和 endDate 日期范围之间
这三个时间就相当于我写的那个列题的 a,b,c
temp.orderdate取出的日期 ----c
strDate -------------------a
endDate -------------------b
你只要套公式一样套就可以了。