Problem in sorting by date field

masoud_sedighy

Registered User.
Local time
Today, 06:51
Joined
Dec 10, 2011
Messages
132
In my table , i have a field and it's data type is date/time and all of values of this field are date. like below for example:

3/4/2015
12/5/2015
Actually i checked with isdate() function this field all returns "true".

Now when i sorting table (ASC) by this field it sorts incorrectly like below:

12/5/2015 (5-dec-2015)
3/4/2015 (4-mar-2015)
Please help how i can solve?
 
Are you sorting the table in data sheet view or a query record set?
 
IsDate will return True if the expression you are testing Will result in a date. it doesn't mean that the datatype is actually a date, it can be a string.

To convert it to true date, cast your expression to CDate or CVDate:

expr1: CDate(field column)
 
Are you sorting the table in data sheet view or a query record set?

I am in data sheet view if a maked query. Query has been sorted by another field, when i click on coulmn header of date field it does not sort properly.
 
IsDate will return True if the expression you are testing Will result in a date. it doesn't mean that the datatype is actually a date, it can be a string.

To convert it to true date, cast your expression to CDate or CVDate:

expr1: CDate(field column)

In the maked query i have made experession with datevalue(field column) and checked this expression with isdate() function that returns true. Actually i do not understand what is difference between usage of datevalue() function and cdate() function?
 
are you sure the field in your table is date/time?
 
are you sure the field in your table is date/time?

Field in my table is text but datevalue() field in my query is data/time. And actually opened this query and try to sort by datevalue() column in query data sheet view.
 
should work if you are using DateValue alone.
 
Thank you, maybe my problem is in designing of query, in designing of query i have sorted by another fields and then i try to sort by date in data sheet view of query. I will change sorting of fields in design query.
 

Users who are viewing this thread

Back
Top Bottom