Print Page | Close Window

Sorting by Date, Please HELP!!!

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=11060
Printed Date: 20 September 2024 at 10:36am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Sorting by Date, Please HELP!!!
Posted By: cmm2006
Subject: Sorting by Date, Please HELP!!!
Date Posted: 16 June 2008 at 3:47pm
I have records in my database that includes the OrderDate, but when I sort the reportcontrol by date, well it's not sorting properly. For instance:
if the OrderDate are as followed: 6/1/08, 6/2/08, 6/3/08, 6/11/08,6/12/08. The correct way the report suppose to be displayed the list is:
6/1/08
6/2/08
6/3/08
6/11/08
6/12/08
but instead, it shows the following:
6/1/08
6/11/08
6/12/08
6/2/08
6/3/08
any help!!!!



Replies:
Posted By: Smucker
Date Posted: 16 June 2008 at 9:52pm
My application works with multiple databases (and has to work across multiple time zones). Some databases don't have a built-in date format. So I store my database dates in ISO 8601 format as UTC (YYYY-MM-DDThh:mm:ss.ssssZ), which collates properly; then convert to local time and user's selected regional settings for display.

I don't know enough about the CJ COM controls (I use MFC) to know how difficult this would be, but there should at least be a callback for item comparison during sorting, wherein you could parse the dates and sort properly by YYYYMMDD.


http://en.wikipedia.org/wiki/ISO_8601 - http://en.wikipedia.org/wiki/ISO_8601


Posted By: Stilki
Date Posted: 16 June 2008 at 11:18pm
From my testing this workaround seems to work.
 
A date/time value can be represented by a numerical number. I use this number and assign it to the Item.Value property.
 
I then format the date/time value to my needs and assign it to the Item.Caption property.
 
The sorting then works fine.
 
eg. (In Visual Basic)
 
Item.Value = CDbl(ADateVariableWithAValue)
Item.Caption = Format$(ADateVariableWithAValue, "dd/mm/yy HH:MM AMPM")


Posted By: Stilki
Date Posted: 17 June 2008 at 12:54am
Also works if you initially pass in a date variable when calling AddItem.
Obviously the reportcontrol determines the data type when calling AddItem.
 
Set Item = Record.AddItem(CDate("15/7/08"))


Posted By: cmm2006
Date Posted: 17 June 2008 at 1:16pm
thank you all,
the CDate did the job.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net