473,394 Members | 1,709 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,394 software developers and data experts.

Not getting the proper data when comparing with dates in MSACCESS

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 3476
AricC
1,892 Expert 1GB
I think this is more of an Access question I will move your thread their.

Aric
Jan 30 '07 #2
Rabbit
12,516 Expert Mod 8TB
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 Expert 8TB
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
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...
13
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...
36
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...
9
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...
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...
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: 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 ...
0
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...
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.