Got a problem with dates, SQL and tables

Results 1 to 2 of 2

Thread: Got a problem with dates, SQL and tables

  1. #1
    Join Date
    Dec 1969

    Default Got a problem with dates, SQL and tables

    Guys,<BR><BR>Here is the problem I am presented with. The client has two tables, one for payments and one for receipts that are identical. They need me to pull the data from both tables and build a ledger so that the data is sorted by date descending.<BR><BR>It will be displayed in the following format:<BR><BR>Date - Detail Payment Receipt Balance<BR> <BR>Depending on whether the value is positive or negative, it goes in the appropriate column. Can I combine the call from the two tables into one SQL call or do I need to read the two tables into two arrays and sort the arrays?<BR><BR>To make matters worse, the "dates" are stored as 8 digit 20030506 in the database and are stored in STRING form. Can I write a SQL Query that uses substrings to put the date in the correct order and do a sort on these dates?<BR><BR>Any help you can provide me with would be appreciated.

  2. #2
    Join Date
    Dec 1969

    Default RE: Got a problem with dates, SQL and tables

    Yes you can do a union query since the fields in the tables have identical structures.<BR><BR>And sorting by date should work just fine even though it&#039;s a string field since it&#039;s got the longest term stuff first: yyyymmdd.<BR><BR>Best regards,<BR>J. Paul Schmidt - Freelance ASP Web Developer<BR> - Creating "dynamic" Web pages that read and write from databases...<BR>

Posting Permissions

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