473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem Comparing Dates!

I have a general date field in a table. When a user opens a particular report, a form opens that asks them to enter a date (short date format) to filter the report by. I want the report to display all records with a date less than or equal to the entered date.

Of course, the problem is that the date entered (in other words, the "equal to" case) returns no data since the general date is LARGER than the short date for the same day since the time portion of the general date adds a decimal to the date value.

How can I compare the general date to the short date and retrieve records when the days are equal? I've tried using Format(GeneralDate, "Short Date") in the comparison but it does not work for some odd reason. I'm even displaying the result in a new column and the formatted general date result looks correctly like a short date, but the "equal to" records are still missing.

:!
Oct 28 '10 #1

✓ answered by dsatino

Just programatically add 1 day to the user entry and switch your comparison operator to <. This will work because the time value of the short date is 00:00:00.

3 1982
NeoPa
32,556 Expert Mod 16PB
The simple answer is to use DatePart() where necessary. More than that I cannot say as I have no idea what your current code is so I have no idea how you're thinking.
Oct 28 '10 #2
dsatino
393 256MB
Just programatically add 1 day to the user entry and switch your comparison operator to <. This will work because the time value of the short date is 00:00:00.
Oct 28 '10 #3
Thank you both for your answers. I ended up using both solutions at once, but for different things. Thanks again!
Oct 28 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Zibi | last post by:
Sometimes I get error : "The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value. " If I look on SQL there is ok example with error - insert...
3
by: Robert Dell | last post by:
I have a problem comparing strings in an order form i'm writing. I want to give a running total at the bottom of the page and it appears to be working except it doesn't compare correctly (it...
14
by: marcokrechting | last post by:
Hi All, I have a rather complex math problem concerning dates. I will try to explain my problem. I have a table with the fields SUBJECT (text), DUE DATE (date) and CHECKED (yes/no). In this...
2
by: Duppypog | last post by:
I'm trying to compare a date stored in a database with today's date using an If statement, but it's not returning true. Example, value in database is 11/5/2003 with today being 11/6/2003. Can...
12
by: colincolehour | last post by:
I am new to Python and am working on my first program. I am trying to compare a date I found on a website to todays date. The problem I have is the website only shows 3 letter month name and the...
5
by: krishnakant Mane | last post by:
hello all. thanks for the help and for pointing me to the proper url for wxpython related issues. I am so happy that I now have a very easy gui library that can do practically every thing with...
4
by: cheryl | last post by:
I am using the PHP.MYSQL and Apache server application in developing my website. I have problem in comparing dates. Website has room reservation, the user will check first the room availability. The...
1
by: RiotZamber | last post by:
Hi, I'm new to DB2 so I apologize if this is a dumb question. :) I have this table with 2 columns col_date (varchar(8)) (eg. 20070813) (yyyyMmdd) col_time (varchar(6)) (eg. 1525) (HHmm) ...
6
by: sabel | last post by:
Hi I am a problem comparing DDC AND "DDC" , the if statement is not working. here is my javascript code var DDC=document.getElementById("<%= hvalue.ClientID %>").value; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.