473,625 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with comparing date

Bob
Hi,

I have a wrong result when testing today against a date fetched from a table
in excel.
The value in excel is: 14/12/2006 (european format).
When today is after that value in excel, the message "time is over" must
appear, otherwise nothing.

My problem is that the message appear already when today = that value.
Any idea why?

When doing response.write( n & " " & dtreader.GetDat eTime(0)), i get:
14/12/2006 18:57:23 14/12/2006

Thanks
Bob
Dim n As Date
n = Date.Now
......
sql = "select mydate from mytable;"
comd = New OleDbCommand(sq l, oConnection)
dtreader = comd.ExecuteRea der
dtreader.Read()
.....
If n dtreader.GetDat eTime(0) Then
response.write( "time is over")
end if

Dec 14 '06 #1
2 1399
Just a thought, but "today at 6:57pm is today at 12:00 am" looks like
what you have there. If there is no time shown it generally means that
the time is the 0s when comparing against something with a time
component.

Try using Date.Today or DateTime.Today to get a "Date" value and not a
"DateTime".

After that it would probably be a good idea to strip of the time from
the DataReader value by calling dtreader.GetDat eTime(0).Date to get the
date portion only.

HTH,
Andrew

Bob wrote:
Hi,

I have a wrong result when testing today against a date fetched from a table
in excel.
The value in excel is: 14/12/2006 (european format).
When today is after that value in excel, the message "time is over" must
appear, otherwise nothing.

My problem is that the message appear already when today = that value.
Any idea why?

When doing response.write( n & " " & dtreader.GetDat eTime(0)), i get:
14/12/2006 18:57:23 14/12/2006

Thanks
Bob
Dim n As Date
n = Date.Now
.....
sql = "select mydate from mytable;"
comd = New OleDbCommand(sq l, oConnection)
dtreader = comd.ExecuteRea der
dtreader.Read()
....
If n dtreader.GetDat eTime(0) Then
response.write( "time is over")
end if
Dec 14 '06 #2
Bob
Thanks both
"Andrew Backer" <aw******@gmail .comschreef in bericht
news:11******** *************@n 67g2000cwd.goog legroups.com...
Just a thought, but "today at 6:57pm is today at 12:00 am" looks like
what you have there. If there is no time shown it generally means that
the time is the 0s when comparing against something with a time
component.

Try using Date.Today or DateTime.Today to get a "Date" value and not a
"DateTime".

After that it would probably be a good idea to strip of the time from
the DataReader value by calling dtreader.GetDat eTime(0).Date to get the
date portion only.

HTH,
Andrew

Bob wrote:
>Hi,

I have a wrong result when testing today against a date fetched from a
table
in excel.
The value in excel is: 14/12/2006 (european format).
When today is after that value in excel, the message "time is over" must
appear, otherwise nothing.

My problem is that the message appear already when today = that value.
Any idea why?

When doing response.write( n & " " & dtreader.GetDat eTime(0)), i get:
14/12/2006 18:57:23 14/12/2006

Thanks
Bob
Dim n As Date
n = Date.Now
.....
sql = "select mydate from mytable;"
comd = New OleDbCommand(sq l, oConnection)
dtreader = comd.ExecuteRea der
dtreader.Read()
....
If n dtreader.GetDat eTime(0) Then
response.write ("time is over")
end if

Dec 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
13115
by: Donnal Walter | last post by:
I was very surprised to discover that >>> import datetime >>> x = datetime.date(2004, 9, 14) >>> y = datetime.datetime(2004, 9, 14, 6, 43, 15) >>> print x == y True How can these two objects be considered equal? Is there a *general* way to test for date != datetime as well as 4.5 != 4.6?
19
7270
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' + str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
1
1814
by: E. Liepins | last post by:
I am working on a vehicle database. We track when a vehicle is borrowed and when it is returned. We also track the number of kilometres travelled on a particular trip. There are several tables: tblLeaders - lists the people, tblVehicle, tblresults - where the info is stored for trips, tblVehicleType- we charge different rates for different types of vehicles. We have 2 main forms frmSignout and frmReturn. My problem occurs when I...
5
4276
by: rjfjohnson | last post by:
Hey, Today is Thursday 16-Feb-06. The same thursday last year is 17-Feb-05. Because I am comparing daily sales between years, I need to know the date of the same weekdayname as last year, so that I am comparing Saturdays with Saturdays, Sundays with Sundays, etc ie, 16-feb-06 goes to 17-feb-05 28-july-06 goes to 27-july-05 and so on
1
6525
by: G Gerard | last post by:
Hello I am having some problem comparing dates with the SQL statement below MySQL = "SELECT Format(Date, 'yyyy/mmmm/dd') as FROM TblDates WHERE _ Format(Date, 'yyyy/mmmm/dd') = #2006/April/18#" Even though the date 2006/April/18 is in TblDates, it is never found by the
2
3379
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function checkInteger(&$value, $checks) { $err = ''; if (!is_numeric($value) || (floatval($value) != intval($value))) { $err .= 'Input must be an integer. ';
4
7403
by: anagai | last post by:
I just want to check if a date entered in a textbox is equal to the current system date. I set the date object from the input field like this: dt1=new Date('10/01/2007'); the current system date is retrieved like this: curDt = new Date();
1
1222
by: cmrhema | last post by:
Hi, I have designed an employee portal. The moment the user logs in and logs out the current datetime will be stored. Before the user logs out I should ensure whether he/she has entered the work done form for that day. I wrote select count(*) from workdone where work_date_time=getdate() If there are any rows that means he/she has filled up the form else not filled. But the query is comparing the date as well as time.
1
1866
by: cdhaynes | last post by:
Hi, I am using unbound text boxes in the header of a form to allow the user to search on a number of fields. I am using VBA to build a query string based on these and it has been fine when comparing text fields on the main form but I have run in to trouble comparing date/time fields on a subform. The subform is called Activity and I am comparing to the date/time field ActivityStartDate. This is the code: If Not IsNull(Me.searchFromDate)...
0
8253
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.