Comparing Time

G

Guest

I have a table in my database that has a DateTime field that stores a time
that I want to compare with the current time in my asp.net vb codes.

The value stored in the field is for example, 01/01/1900 11:00:00. So
actually I'm only interested with 11:00 am. And let's say the time I want to
compare with is 26/09/2005 08:06:05; then I would like to compare 8:06 am
with 11 am. If the time is later than 11 am, I'll want to add another day to
a particular date. So in this case, nothing will be done.

Here's how my codes look like,

Dim req As DelRequest = GetRequest(CustID, ReqNo)
Dim acceptableDate As DateTime = DateAdd("d", 1, req.ReqSendOn)

Dim CustControl As New CustomerController
Dim SecondDLTime As DateTime =
FormatDateTime(CustControl.GetSecondDLTime(CustID), DateFormat.ShortTime)
Dim ReqTime As DateTime = FormatDateTime(req.ReqSendOn, DateFormat.ShortTime)

If DateDiff(DateInterval.Second, ReqTime, SecondDLTime) < 0 Then

acceptableDate = DateAdd("d", 1, acceptableDate)

End If

acceptableDate is the date that I want to add another day with if the value
in the table is earlier than the time I want to compare with. SecondDLTime is
the time when I want to compare with, while ReqTime is the time that is
stored in the table. So if ReqTime is later than SecondDLTime, I will add
another day to the acceptableDate.

But, the codes quoted above doesn't work. The DateDiff(DateInterval.Second,
ReqTime, SecondDLTime) < 0 statement doesn't work. No date is added. Can
anyone please help me. Thank you.
 
G

Guest

you have to: convert it double by using date.tooaddate (double) and do u
comparison.

Ocurnos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top