时间范围计算? [英] Time Range Calculation?
问题描述
我想知道现在是否()是在上午9点到下午5点之间我已经尝试了很多东西但是不能让它起作用。
谢谢
I''m trying to find out if now() is between 9:00 AM and 5:00 PM I''ve tried
a few things but can''t get it to work.
Thanks
推荐答案
在消息< uA ********** ****@TK2MSFTNGP14.phx.gbl> ;, Bdog
< bd *** @ Hotmail.com>写道
In message <uA**************@TK2MSFTNGP14.phx.gbl>, Bdog
<bd***@Hotmail.com> writes
我正在试图找出现在()是否在上午9:00到下午5:00之间我已经尝试了一些但却无法得到的东西它可以工作。
I''m trying to find out if now() is between 9:00 AM and 5:00 PM I''ve tried
a few things but can''t get it to work.
你试过吗:
如果小时(现在)> = 9小时(现在) < = 17那么
''做点什么
结束如果
-
Andrew D. Newbould E - 邮件: ne********@NOSPAMzadsoft.com
ZAD Software Systems网站: www.zadsoft.com
谢谢我会尝试一下,如果我想从8:30到
4:30,怎么处理呢?
谢谢
Barclay
" Andrew D. Newbould" <是ne ******** @ NOzadSPANsoft.com>在消息中写道
news:uo ************** @ zadsoft.gotadsl.co.uk ...
Thanks I''ll try it, any idea on how to handle it if I want from 8:30 to
4:30?
Thanks
Barclay
"Andrew D. Newbould" <ne********@NOzadSPANsoft.com> wrote in message
news:uo**************@zadsoft.gotadsl.co.uk...
在消息< ; uA ************** @ TK2MSFTNGP14.phx.gbl> ;, Bdog
< bd *** @ Hotmail.com>写道
In message <uA**************@TK2MSFTNGP14.phx.gbl>, Bdog
<bd***@Hotmail.com> writes
我正在试图找出现在()是否在上午9:00到下午5:00之间我已经尝试了一些东西,但是不能得到它工作。
I''m trying to find out if now() is between 9:00 AM and 5:00 PM I''ve trieda few things but can''t get it to work.
你有没有尝试过:
IF小时(现在)> = 9小时(现在)< = 17那么
做点什么
结束如果
-
Andrew D. Newbould电子邮件: ne ******** @ NOSPAMzadsoft.com
ZAD Software Systems Web: www.zadsoft.com
2005-06-08,Bdog< bd * **@Hotmail.com>写道:
On 2005-06-08, Bdog <bd***@Hotmail.com> wrote:
谢谢我会尝试一下,如果我想从8:30到4:30请问如何处理它?<br />
谢谢
巴克莱
Thanks I''ll try it, any idea on how to handle it if I want from 8:30 to
4:30?
Thanks
Barclay
巴克莱,看看DateTime对象的比较方法...
昏暗开始为新日期_
(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day,8,30,0)
Dim end As New Date _
(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day,16,30,0)
Dim currentTime As Date = Date。现在()
如果Date.Compare(currentTime,begin)> = 0并且_
Date.Compare(currentTime,end)< = 0那么
''做酷的东西
结束如果
如果你不想让它包容,那么删除等号: )
-
Tom Shelton [MVP]
Barclay, look at the DateTime objects compare method...
Dim begin As New Date _
(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 30, 0)
Dim end As New Date _
(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 16, 30, 0)
Dim currentTime As Date = Date.Now ()
If Date.Compare (currentTime, begin) >= 0 And _
Date.Compare (currentTime, end) <= 0 Then
'' Do Cool Stuff
End If
If you don''t want it to be inclusive, then remove the equal signs :)
--
Tom Shelton [MVP]
这篇关于时间范围计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!