Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Thanked 0 Times in 0 Posts

    Excel-like date calculations

    I have created a very easy spreadsheet which enables the user to calculate the day on which the medication supply runs out.

    The sheet considers
    • number of tablets available
    • number of tablets to take per day (1 or 2)
    • start date

    By dividing the number of tablets by the number of days, the function will provide the total number of days which the medication will cover. By using MIN it will round the number to the next lower integer. At the end it substract the output by one (due to the fact that the first tablet is already taken on the start date).

    Now I would like to make this available on a website as a calculator. It should be something like a form where only the yellow fields can be edited. Does anyone have an idea which tools I could use for this? Ideally, it should be possible to embed this in an wordpress page.

    Many thanks in advance.



    (you can see the spreadsheet in the attachment)
    Attached Thumbnails Attached Thumbnails -spreadsheet-png  

  2. #2
    Regular Coder
    Join Date
    Jun 2002
    Flint, Michigan, USA
    Thanked 23 Times in 23 Posts
    Maybe this will help:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
        <title>Medicine Supply</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Script-Type" content="text/javascript" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <meta http-equiv="Content-Language" content="en-US" />
        <meta name="Author" content="James Alarie - jalarie@umich.edu" />
        <meta name="description" content="Calculate the day on which the medication supply runs out." />
        <meta name="keywords" content="calculate,day,medication,supply" />
        <script type="text/javascript">
      function ComputeIt() {
        f1=document.forms[0];                           // abbreviation
        I_StartDate       =f1.F_StartDate.value;
        I_NumberPerDayI   =f1.F_NumberPerDay.selectedIndex;
        I_NumberPerDay    =f1.F_NumberPerDay.options[I_NumberPerDayI].value;
        S_StartDate=new Date(I_StartDate)*1;            // milliseconds since 1970-01-01
        S_StartDate=S_StartDate/(24*60*60*1000);        // ...days as a decimal
        S_StartDate=Math.floor(S_StartDate);            // ...days integer
        S_Date=new Date((S_OutOfSupplyAfter*1+1)*24*60*60*1000);
        S_Year =S_Date.getFullYear();
        S_Month=S_Date.getMonth()*1+1;                  // month as 1-12
        S_Date =S_Date.getDate();
        return true;
      } // ComputeIt
      <body class="body1">
       <div id="body">
    <!-- Page Header -->
        <div id="header">
          <h1>Medicine Supply</h1>
          <hr />
    <!-- Content -->
        <div id="content">
          <br />
            <p class="notice">
              You must have scripting enabled to make full use of this page.
          <div class="center">
            <form method="post" action="javascript:void(0);">
             <div class="form">
              <table border="1" cellspacing="2" cellpadding="2"
                  summary="This table is used for layout purposes only.">
                <caption class="caption2"><b>Medication Supply</b></caption>
                      <label for="F_StartDate">Start Date</label>
                      <input type="text" size="20" value="?" name="F_StartDate" id="F_StartDate" alt="First date" onfocus="this.select();" />
                      as YYYY-MM-DD
                      <label for="F_AvailableTablets">Available Tablets</label>
                      <input type="text" size="20" value="?" name="F_AvailableTablets" id="F_AvailableTablets" alt="Number of Available Tablets" onfocus="this.select();" />
                      Enter the number of tablets that you have
                      <label for="F_NumberPerDay">Number per Day</label>
                      <select name="F_NumberPerDay" id="F_NumberPerDay">
                      How many do you take each day?
                    <td colspan="3">
                      <input type="button" value="Compute" onclick="ComputeIt();" />&nbsp; 
                      <input type="reset" value="Reset" title="Reset" />&nbsp; 
                      <label for="F_OutOfSupplyAfter">Out of Supply After</label>
                      <input type="text" size="20" value="?" name="F_OutOfSupplyAfter" id="F_OutOfSupplyAfter" alt="Take the last Tablet on this Date" onfocus="this.select();" />
                      result:&nbsp; take the last tablet on this date
             </div><!-- form -->
          </div><!-- center -->
    <!-- Page Footer -->
        <div id="footer">
          <br clear="all" /><hr />
          Written on December 23, 2012, by:&nbsp;
          <a href="mailto:jalarie@umich.edu">James Alarie</a>.
    Having said that, I've probably told you more than I know.


Posting Permissions

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