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

DateTime order

115 100+
hey all
I have a small but very annoying problem.
I collect two sets of data from two different databases, This data is now in two collections. I then join/append the one collection to the other and then put it in to a list view.
That part works

I really would like to order this list view by the first column without the click event.
To make this even harder the First column contains Data that is DateTime and i have found that it orders the items by the day number and not the months or years or time.

I have found one way but it then cause's me further agony when doing some checks upon the data within the listview later in my code. This answer is to rearrange the format to "yyyy-MM-dd HH:mm:SS"
then using the listview.sorting = sortorder.The order you wish

Any suggestions would be muchly appreciated

cheers

Truez
Feb 5 '09 #1
7 1115
jg007
283 100+
what about " DataTableName.DefaultView.Sort = "DataColumnName" '
Feb 5 '09 #2
truezplaya
115 100+
Possibly would work if the data was in a dataTable
Feb 5 '09 #3
jg007
283 100+
sorry, I was not clear how you were getting it from the database to the list box so assumed that you were getting a datatable from an oledb query and then using it as the datasource.
Feb 5 '09 #4
truezplaya
115 100+
i do but i get them from two differnet sources then add them both to a collection. I then merge these collections, this is when i would like to do the sort.
Feb 5 '09 #5
truezplaya
115 100+
Here is a solution that someone i know came up with.
temp is a myCollection that has data in it
Expand|Select|Wrap|Line Numbers
  1. Dim sortedCollection As New myCollection
  2.  
  3.         For index As Integer = 0 To (temp.Count - 1)
  4.  
  5.             Dim highestDate As DateTime = Nothing
  6.             Dim hightestIndex As Integer = 0
  7.  
  8.             For subIndex As Integer = 0 To (temp.Count - 1)
  9.  
  10.                 If temp(subIndex).committedToSort = False Then
  11.                     If temp(subIndex).sortDateTime > highestDate Then
  12.                         hightestIndex = subIndex
  13.                         highestDate = temp(subIndex).sortDateTime
  14.                     End If
  15.                 End If
  16.  
  17.             Next
  18.  
  19.             sortedCollection.Add(temp(hightestIndex))
  20.  
  21.             temp(hightestIndex).committedToSort = True
  22.  
  23.         Next
  24.  
Feb 12 '09 #6
Plater
7,872 Expert 4TB
Why not join them into a DataTable and then sort it, and then use that as a datasource?
Feb 12 '09 #7
truezplaya
115 100+
I was editing someone else's code and they have done everything in collections and i thought i would do it the way you suggested but to add to the difficulty of the situation the data was coming from two different databases so the dates were different formats, one a timestamp and one dateTime i believe. To keep the flow of the code i thought since it's been put in to a collection i will keep it in this format as i am not totally familliar with the concept of the programming that has been use. This is when i got some help and they came up with that little bad boy!
Feb 12 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Donnal Walter | last post by:
I was very surprised to discover that >>> import datetime >>> x = datetime.date(2004, 9, 14) >>> y = datetime.datetime(2004, 9, 14, 6, 43, 15) >>> print x == y True How can these two...
4
by: John Hunter | last post by:
>>> from datetime import date >>> dt = date(1005,1,1) >>> print dt.strftime('%Y') Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: year=1005 is before 1900; the...
2
by: bncarper | last post by:
Relatively new to python. I can get the following to work from the command line: Python 2.3.4 (#2, Aug 18 2004, 21:49:15) on linux2 Type "help", "copyright", "credits" or "license" for more...
1
by: antao | last post by:
I'm keeping in the database a log of all the sessions for my application. I'm trying to write a stored procedure that returns all the sessions that; the login contains a certain string, loggedin...
14
by: ChrisM | last post by:
Could anyone please tell me the difference between these 2 lines: myDate = DateTime.Now; and myDate = DateTime.Parse(DateTime.Now.ToString("dd/MM/yyyy")); Seeing as later on in the...
15
by: Fritz Switzer | last post by:
I'd like to have a string assigned the value of a DateTime.AddMinutes(amount) so that the string is formatted in "HH:MM" format. For example: DateTime.Now.AddMinutes(30) returns "00:30" ...
5
by: Annie | last post by:
hello guys, I have little experience working with C# and MS Access ... I am having an insert query with one datetime field and a boolean and couple of text and number fields as below: ...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
5
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field...
9
by: Tony Van | last post by:
They're driving me nuts, especially with the Datareader. There are times when I want to pass a null date on to a date variable and I have to cast the null as a date!!!??? I'm wondering if I...
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:
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.