Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


date sensitive array?

date sensitive array?

date sensitive array?

I currently maintain an Excel spreadsheet that contains fairly static information about some of the drugs used at our clinic.  I save this spreadsheet as a csv file and read it into an array.  I use the name of the drug as the key, and access the array to pull off manufacturer name, unit price, etc.  My users now want to make this table date sensitive.  For instance, unit price may change from time to time.  The users are envisioning adding two more columns to the table to create an effective date range.  Then based on the date that the drug was administered, the unit price, etc would be pulled for that date range.  The name of the drug will no longer be unique to the table.  Is there a way to make my array date sensitive and still keep the structure and programming fairly intact?  Or would a rewrite using lists actually be simpler?  My apologies for being so long-winded.

RE: date sensitive array?


I would just dump the CSV & Excel idea and put the data where they should be : in a database.

This means some work to done, but adding new features in the further will be easier.

The data structure would be something like :

drug              price
id | name         id | drugid | price | begin      | end
---+-----         ---+--------+-------+------------+-----------
 1 | Foo           1 |      1 |  1.01 | 2012-01-01 | 2012-01-31
 2 | Bar           2 |      2 |  2.01 | 2012-01-01 |
                   3 |      1 |  1.02 | 2012-02-01 |

Then you could query the prices like this :

CODE --> PostgreSQL

-- get current prices
from drug d
inner join price p on p.drugid=d.id
where p."end" is null;

-- get prices valid on 2012-01-15
from drug d
inner join price p on p.drugid=d.id
where '2012-01-15' between p.begin and coalesce(p."end",now());


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close