473,770 Members | 7,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Not getting the proper data when comparing with dates in MSACCESS

1 New Member
Have created a table with different fields which includes date as one fields

when i executed the following query, i am not getting the data whose date is less than the specified date.

SELECT *
FROM shiftdetails
WHERE format(Date_of_ Shift,'mm/dd/yyyy')<'1/1/2007'
ORDER BY [shiftdetails].[Date_of_Shift] DESC;


can anybody help me
Jan 30 '07 #1
3 3492
AricC
1,892 Recognized Expert Top Contributor
I think this is more of an Access question I will move your thread their.

Aric
Jan 30 '07 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Have created a table with different fields which includes date as one fields

when i executed the following query, i am not getting the data whose date is less than the specified date.

SELECT *
FROM shiftdetails
WHERE format(Date_of_ Shift,'mm/dd/yyyy')<'1/1/2007'
ORDER BY [shiftdetails].[Date_of_Shift] DESC;


can anybody help me
I wouldn't suggest using strings to compare dates. If, for some reason, you need to compare dates using strings, you'll need to use "yyyy/mm/dd" as the format. For single digit months and days, you'll need to append a 0 in front.

--> format(Date_of_ Shift, 'yyyy/mm/dd') < '2007/01/01'

The problem with strings and dates is that it compares the characters starting from left to right. What I suggest is to compare using date values.

--> Date_of_Shift < #1/1/2007#
Jan 30 '07 #3
ADezii
8,834 Recognized Expert Expert
Have created a table with different fields which includes date as one fields

when i executed the following query, i am not getting the data whose date is less than the specified date.

SELECT *
FROM shiftdetails
WHERE format(Date_of_ Shift,'mm/dd/yyyy')<'1/1/2007'
ORDER BY [shiftdetails].[Date_of_Shift] DESC;


can anybody help me
For your comparison to work [Date_of_Shift] must be defined as Date/Time and it cannot be compared to a String as previously indicated (#1/1/2007# should be used instead of '1/1/2007')
Jan 30 '07 #4

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

Similar topics

2
1838
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 someone spot the problem? Thanks, Lynnette Here's the code: sSQL = "Select PWExpire FROM tblUsers where strUserName = '" & stUser & "' AND strPassword = '" & hshPW & "'"
13
10146
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the parent table. ----------------------------
36
3209
by: Chuck Faranda | last post by:
I'm trying to debug my first C program (firmware for PIC MCU). The problem is getting serial data back from my device. My get commands have to be sent twice for the PIC to respond properly with the needed data. Any ideas? Here's the code in question, see any reason why a command would not trigger the 'kbhit' the first time a serial command is sent?: Thanks! Chuck **************************************************** while(1) //...
9
1955
by: Ben R. | last post by:
Hi guys, I've got a DB table of timecards with these fields in the table: ID (Int) UserID (Int) DateWorked (DateTime) HoursWorkedOnThatDate (Double) I'd like to display a grid, with Monday - Sunday across the top (in columns)
12
5563
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 date. Example: Jun 15 How would I go about comparing that to a different date? The purpose of my program is to load a webpage and see if the content on the front page is fresh or stale as in older than a few days. Any help in the right direction...
4
2353
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 user will input dates using the combo box like cboyear,cboday and cbomonth. What SQL statement or quey should I write to compare it to the database. The database has already have value in dates. I want to compare the input date to the database.......
1
1786
by: kigoobe | last post by:
Well guys, I am storing data in the mysql which when extracted gives this - Array ( => Array ( => 26 => 2007-11-01 => 16:01:00 => 08:00:00
0
901
by: riyap | last post by:
Hi i have a question regarding a update in msaccess DB using string builder,DATA SET AND DATA RELATIONS can we do that in access DB i have a table in access i need to pass more than 1 record and get o/p value and update in table again so for this i used : i have 2 datatables which i loaded with select command n records in dlog1 ,dlog2 so im passing log 1 values into oracle stored procedure ,i got the values and im loading it in log3...
8
2524
by: Innocent2104 | last post by:
Hi there, The script below displays the attached output but as shown, it skips certain days and i need to include these to calculate my avg balance for a certain month, i.e.Nov. How do i update the script to include for example between 01 Nov and 05 Nov, there was no entries, therefore my balance should remain the same & display my missing dates 02,03,04 Nov?? DECLARE @STARTDATE DATETIME, @ENDDATE DATETIME SET @STARTDATE = '2009-11-01' ...
0
9425
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
10004
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
9870
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
8886
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...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
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.