Click here to Skip to main content
15,888,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
SELECT     FileNo, ReqControlNo, Requester, ReqDate, ReqTime, IssueDate, IssueTime, DueDate, RequesterDeptt, HandOverTo, ReceivedDate,
                      ProjectName
FROM         Issue
WHERE     (format(IssueDate, 'dd-mm-yyyy') BETWEEN format(?, 'dd-mm-yyyy') AND format(?, 'dd-mm-yyyy'))



I have taken IssueDate as text In Table.
When I find data between same date it retrieves right results.
But when I find data between different date It retrieves Wrong results.
For Example:
From 25-07-2011 to 25-07-2011 returns Right results.
From 23-07-2011 to 25-07-2011 returns wrong results, It picks result of between 23 to 25.It does not check Months.
Please Help me.
Posted
Comments
Mycroft Holmes 25-Jul-11 1:40am    
What database are you using, you should not need formatting in a select statement.
uspatel 25-Jul-11 1:53am    
MS Access 2007

1 solution

Always, ALWAYS use unambiguous date formats either yyyy-mm-dd or dd-MMM-yyyy.
 
Share this answer
 
Comments
uspatel 25-Jul-11 1:53am    
I have already used dd-mm-yyyy formate.
Mycroft Holmes 25-Jul-11 1:56am    
Sure you did and it is WRONG, try using dd-MMM-yyyy, the 3 cap Ms will force a text month into the query.
uspatel 25-Jul-11 2:05am    
But I take dd-mm-yyyy format in access database.It contains more than 8000 records.
Can this format be change without affecting my application?
Mycroft Holmes 25-Jul-11 2:15am    
Please don't tell me your date data is stored as text values. If so then you URGENTLY need to change to the proper datetime format, if you don't then there is no way to help you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900