3 个解决方案
#1
start = "2012-6-16 0:0:0"
endt = "2012-6-17 0:0:0"
if datediff("s", start, now()) > 0 and datediff("s", now(), endt) > 0 then
response.write "在规定的时间范围内"
end if
参考
http://www.w3school.com.cn/vbscript/func_datediff.asp
endt = "2012-6-17 0:0:0"
if datediff("s", start, now()) > 0 and datediff("s", now(), endt) > 0 then
response.write "在规定的时间范围内"
end if
参考
http://www.w3school.com.cn/vbscript/func_datediff.asp
#2
楼上正确。使用datediff,mssql里面也有这个函数。
#3
我试试,我也找到了一种方法,分享一下:t.Start,t.Endtime为数据库中时间
DateTime time1 = DateTime.Parse(t.Start);
DateTime time2 = DateTime.Parse(t.Endtime);
DateTime n = DateTime.Now;
int num1=DateTime.Compare(time1, n);
int num2 = DateTime.Compare(time2, n);
if (num1 > 0 ||num2 <= 0)
{
allow = 0;
}
if (num1 <= 0 && num2 > 0)
{
allow = 1;
}
DateTime time1 = DateTime.Parse(t.Start);
DateTime time2 = DateTime.Parse(t.Endtime);
DateTime n = DateTime.Now;
int num1=DateTime.Compare(time1, n);
int num2 = DateTime.Compare(time2, n);
if (num1 > 0 ||num2 <= 0)
{
allow = 0;
}
if (num1 <= 0 && num2 > 0)
{
allow = 1;
}
#1
start = "2012-6-16 0:0:0"
endt = "2012-6-17 0:0:0"
if datediff("s", start, now()) > 0 and datediff("s", now(), endt) > 0 then
response.write "在规定的时间范围内"
end if
参考
http://www.w3school.com.cn/vbscript/func_datediff.asp
endt = "2012-6-17 0:0:0"
if datediff("s", start, now()) > 0 and datediff("s", now(), endt) > 0 then
response.write "在规定的时间范围内"
end if
参考
http://www.w3school.com.cn/vbscript/func_datediff.asp
#2
楼上正确。使用datediff,mssql里面也有这个函数。
#3
我试试,我也找到了一种方法,分享一下:t.Start,t.Endtime为数据库中时间
DateTime time1 = DateTime.Parse(t.Start);
DateTime time2 = DateTime.Parse(t.Endtime);
DateTime n = DateTime.Now;
int num1=DateTime.Compare(time1, n);
int num2 = DateTime.Compare(time2, n);
if (num1 > 0 ||num2 <= 0)
{
allow = 0;
}
if (num1 <= 0 && num2 > 0)
{
allow = 1;
}
DateTime time1 = DateTime.Parse(t.Start);
DateTime time2 = DateTime.Parse(t.Endtime);
DateTime n = DateTime.Now;
int num1=DateTime.Compare(time1, n);
int num2 = DateTime.Compare(time2, n);
if (num1 > 0 ||num2 <= 0)
{
allow = 0;
}
if (num1 <= 0 && num2 > 0)
{
allow = 1;
}