Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have access database ,which contains date as one column,based on that date value need to get values.
In my access db
Column name PDate and its datatype is Date/Time and General Date format "5/8/2015 3:58:39 PM"

below is my data in Access db

SQL
BMID    UserId    PDate                    PName
50      1        5/8/2015 3:58:39 PM     Aravind
51      1        6/8/2015 3:59:47 PM     Aravind
52      1        8/8/2015 4:01:09 PM     Aravind
53      1       10/8/2015 4:02:29 PM     Aravind
54      1       12/8/2015 4:03:19 PM     Aravind
55      1       14/8/2015 4:04:39 PM     Aravind
56      1       16/8/2015 4:19:39 PM     Aravind



From above if i try to use select query in access db like

SQL
Select BMID,UserId,Format([PDate],'dd-MM-yyyy') as PDate1,PName From BodyMeasurements where UserId=1 And BodyMeasurements.[PDate]  between #19/07/2015 12:00:00 AM# and #18/08/2015 11:59:59 PM#


i can get result all 7 rows,if end date is "14/08/2015 11:59:59 PM" i can get top 6 rows,but if end date is "12/08/2015 11:59:59 PM" i can get all 7 rows as result.

pls reply me how to correct values if date is 12 and below

Regards
Aravind
Posted

1 solution

This sounds like the Access is interpreting your date as dd/mm in the first case and mm/dd in the second.

Try using format yyyy-mm-dd which should always be interpreted correctly. In other words
SQL
Select BMID,UserId,Format([PDate],'dd-MM-yyyy') as PDate1,PName 
From BodyMeasurements 
where UserId=1 
And BodyMeasurements.[PDate]  between #3015-07-19 12:00:00 AM# and #2015-08-18 11:59:59 PM#
 
Share this answer
 

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



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