Groups | Blog | Home
all groups > c# > april 2007 >

c# : how to do that


Ricardo Luceac
4/2/2007 5:49:35 PM


Hi all...

I know this isn't the right place for that but i'm with this problem..


I work in a hospital and need to make a program that counts the amount
of people interned per day. I have in a mysql database the day that the
person interned and the day that it leaves.
tHow can I count that the person is interned in the middle days??? I
need to make a graph of that.


Some ideas???

Michael A. Covington
4/2/2007 9:25:34 PM
[quoted text, click to view]

Suppose you had to do it by hand. How would you do it?

Write down a small example on a piece of paper. Don't think about MySQL or
about C#. Think about how to figure out how many people are in the hospital
on a particular day.

Michael C
4/3/2007 12:00:00 AM
[quoted text, click to view]

SELECT COUNT(*) FROM SomeTable WHERE DateIn <= GetDate()AND (DateOut >=
GetDate() OR DateOut IS NULL)

I'm not sure what the function is in mysql to get the current date, in
SQLServer it is GetDate().

Michael

Rune Jacobsen
4/4/2007 12:00:00 AM
[quoted text, click to view]

In MySQL the function is now().

If you also want to see how many were admitted per date in a certain
timespan, you could do something like this (psuedo-SQL):

SELECT count(*) AS numpatients, DATE(DateIn) AS interned
FROM SomeTable
WHERE DATE(DateIn) <= 'Start date' AND Date(DateIn) >= 'Stop date'
GROUP BY DATE(DateIn)

Not tested, but shouldn't be far off. :)

Göran_Andersson
4/4/2007 9:04:23 PM
[quoted text, click to view]

Well, it's close, but it's also the total opposite. ;)

WHERE DATE(DateIn) >= 'Start date' AND Date(DateIn) <= 'Stop date'

--
Göran Andersson
_____
Rune Jacobsen
4/4/2007 10:09:22 PM
[quoted text, click to view]

AddThis Social Bookmark Button