-
August 18th, 2017, 03:13 PM
#1
VB.net code between two dates
I have the following code:
This one working ok,
Code:
Dim a As Date = "08/19/2017 02:00:00 PM"
Dim b As Date = "08/19/2017 22:00:00 PM"
If Now >= CDate(a) And Now <= CDate(b) Then
MsgBox("ok")
Else
MsgBox("Not ok")
End If
But this one not working
Code:
Dim a As Date = "08/19/2017 08:00:00 PM"
Dim b As Date = "08/20/2017 06:00:00 AM" 'next day
If Now >= CDate(a) And Now <= CDate(b) Then
MsgBox("ok")
Else
MsgBox("Not ok")
End If
any advice please
Last edited by kmafsar; August 18th, 2017 at 05:59 PM.
Reason: Added code tags
-
August 19th, 2017, 06:37 AM
#2
Re: VB.net code between two dates
hmm. given that you posted this at 4:13pm on 8/18 I don;t see how either of them could have given you the "ok" message.
Of course you just said not working so I don't really know what you mean by that.
It is worth noting that aside from the Dim statements you are basically using VB6 code there rather than VB.Net code
Also of note; why are you using cDate()? both vars are already date type so there is no reason to convert a date to a date.
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|