Results 1 to 4 of 4
  1. #1
    nitish.dhar is offline Member
    Join Date
    Jun 2008
    Posts
    4
    Rep Power
    0

    Default viewing records ordered by date

    actually i have inserted the "date" in msaccess database table using "dd-mm-yy" format
    now i want to view records of that table in ascending order of the date

    so i wrote the query:

    Select * from TRANSACTIONS order by aco_date ASC,aco_time ASC";

    but the problem is if i write this it compares the day first and then the month and then the year since i have inserted the date in dd-mm-yy
    but logically it should compare the year first then the month and then the day...hw can i do that?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    By defining the column as a Date column in the DB rather than a varchar column.

    A stop-gap solution is to use the to_date SQLFunction on the columns.

  3. #3
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    Even if you want to store the string characters rather than as a Date, which is much better in all cases, you don't want to store it as MM-dd-YY or dd-MM-yy for a very simple reason:

    you can't do arithmetic or comparisons on it. Store it as YYYYMMDD and then you can do trivial sorting, comparisons, etc.

  4. #4
    nitish.dhar is offline Member
    Join Date
    Jun 2008
    Posts
    4
    Rep Power
    0

Similar Threads

  1. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 08:32 PM
  2. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 04:15 PM
  3. Getting number of records (JDBC 2.0)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-11-2008, 08:51 AM
  4. Number of updated records
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-21-2008, 04:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •