how to do that

  • Thread starter Thread starter Ricardo Luceac
  • Start date Start date
R

Ricardo Luceac

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???
 
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.

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.
 
Ricardo Luceac said:
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.

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
 
Michael said:
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().

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. :)

Rune
 
Rune said:
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. :)

Rune

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

WHERE DATE(DateIn) >= 'Start date' AND Date(DateIn) <= 'Stop date'
 
Göran Andersson said:
Well, it's close, but it's also the total opposite. ;)

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

Sigh. I was hung over. What can I say? ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top