|
-
Jan 29th, 2003, 11:52 AM
#1
Thread Starter
Frenzied Member
date problem
I'm testing to see if a date is current. This code works fine, except it returns the error message when todays date is chosen. I'm using the < sign, why is it returning the error message for todays date?
Code:
If CDate(txtIntDisStartDate.Text) < Now Then
lblErr.Text = "Display Start Date must be current"
Exit Sub
End If
-
Jan 29th, 2003, 12:22 PM
#2
Member
Try
If CDate(txtIntDisStartDate.Text) < Now.Date Then
lblErr.Text = "Display Start Date must be current"
Exit Sub
End If
This should compare just the date and not include the time
Harold Hoffman
-
Jan 29th, 2003, 01:23 PM
#3
Registered User
HAROLD HOFFMAN is quite correct, your CDate convertion gives you a value wich has the time 00:00 and VERY often that will be smaller than the now value that gives you the time where you call the function. So either try what HAROLD suggested or maybe convert all dates to short dates with Date.ToShortDateString and compare strings.
-
Jan 29th, 2003, 01:54 PM
#4
Sleep mode
VB Code:
Dim tody As Date
Dim mydate As Date
mydate = tody.Today
If mydate = tody.Today Then
'put your code
End If
would this helps !!
-
Jan 29th, 2003, 03:01 PM
#5
Thread Starter
Frenzied Member
thanks Harold, that worked...I need to check if a date is one day after another date selected...is this correct?
Code:
If CDate(txtPreBidOpenDate.Text) = DateAdd(DateInterval.Day, 1, CDate(txtBidOpenDate.Text))
-
Jan 29th, 2003, 03:01 PM
#6
Thread Starter
Frenzied Member
thanks Harold, that worked...I need to check if a date is one day after another date selected...is this correct?
Code:
If CDate(txtPreBidOpenDate.Text) = DateAdd(DateInterval.Day, 1, CDate(txtBidOpenDate.Text))
-
Jan 29th, 2003, 03:35 PM
#7
Member
I would probably use the following to make sure that you are comparing only the date component and not the time component if there is one.
If CDate(txtPreBidOpenDate.Text).Date = DateAdd(DateInterval.Day, 1, CDate(txtBidOpenDate.Text).Date)
Harold Hoffman
-
Jan 30th, 2003, 08:08 AM
#8
Thread Starter
Frenzied Member
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
|