VBA从当前日期返回Meridiem(AM / PM)

时间:2015-07-15 15:26:28

标签: vba

Year(Now)返回当前年份

Month(Now)返回当前月份

Day(Now)返回当前日

Hour(Now)返回当前的小时

Minute(Now)返回当前分钟

你如何回复上午/下午?

2 个答案:

答案 0 :(得分:3)

尝试使用以下

<form action="print.php" method="POST" name="form1" id="form1">
     <table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="table" style="width:700px">
       <tbody>
         <tr>
           <td height="19" colspan="2" valign="middle" class="to" style="width:450px" ><div class="logo"></div></td>
           <td width="95" rowspan="2" valign="bottom"><div class="date">Date:
             <label>
               <input name="date" type="text" readonly id="date" value="07/15/2015" size="10" />
             </label>
           </div></td>
           <td width="106" rowspan="2" valign="bottom" class="po" style="width:100px" ><div class="date">PO: <span id="sprytextfield3">
             <label>
                              <input name="po" readonly  type="text" value="14739" />
               <input type="hidden" name="oldid" value="11810">
              </label>
             <span class="textfieldRequiredMsg">A value is required.</span></span></div></td>
</tr>
         <tr>
           <td height="20" colspan="2" valign="middle" class="to" style="width:450px" ><div class="toheader">To: <span id="spryselect1">
             <label>
               <select name="to" id="to">
                 <option selected="selected" disabled="disabled">Select One</option>
                                  <option value="1">Kum-N-Go</option>
                                 </select>
              </label>
             <span class="selectRequiredMsg">Please select an item.</span></span>
             <input name="time" type="hidden" id="time" value="
                11:13:33                ">
           </div></td>
</tr>
         <tr>
           <td colspan="2" style="height:125px" ><b> Reason For Gas Ticket: </b> <br>
             <span id="spryselect2">
               <label>
                 <select name="reason" id="reason">


              <option selected="selected" disabled="disabled">Select One</option>
                   <option value="Advertising">Advertising</option>
                   <option value="Auction">Auction</option>
                 </select>
               </label>
               <span class="selectRequiredMsg">Required</span></span><br>
               <br>
Car Borrowed From Another Dealership? <br>
<span id="spryselect3">
<label>
  <select name="borrowed" id="borrowed">
    <option selected="selected" disabled="disabled">Select One</option>
    <option value="Yes">Yes</option>
    <option value="No">No</option>
  </select>
</label>
<span class="selectRequiredMsg">Please select an item.</span></span><br></td>
           <td><b>stk/vin/RO#:</b><br>
             <span id="sprytextfield2">
               <label>
                 <input name="stk_vin" type="text" id="stk_vin" onclick="return stk()" size="12" />
               </label>
               <span class="textfieldRequiredMsg"><br />
                 Stock or Vin .</span></span></td>
           <td align="center"><b> Amount<br>
             <div class="money"><span id="spryselect5">
               <label><b>
                 <select name="amount" id="amount">
                   <option value="5.00" selected="selected">5.00</option>
                   <option value="1.00">1.00</option>
                   <option value="2.00">2.00</option>
                   <option value="3.00">3.00</option>
                   <option value="4.00">4.00</option>
                   <option value="5.00">5.00</option>
                   <option value="6.00">6.00</option>
                   <option value="7.00">7.00</option>
                   <option value="8.00">8.00</option>
                   <option value="9.00">9.00</option>
                   <option value="10.00">10.00</option>

                 </select>
               </b></label>
               <span class="selectRequiredMsg">Please select an item.</span></span></div>
</b></td>
</tr>
         <tr>
           <td width="257">Employee Requesting Po:<span id="spryselect9">
             <label>
               <select name="emp" id="acc">
                 <option selected="selected" disabled="disabled">Select One</option>

                                      <option value="5223">5223</option>
                                    </optgroup>

               </select>
             </label>
             <span class="textfieldRequiredMsg">Required</span><span class="textfieldInvalidFormatMsg">Required</span></span></td>
           <td width="219">Acc #:<span id="spryselect4">
             <label>
               <select name="acc" id="acc">
                 <option selected="selected" disabled="disabled">Select One</option>
                 <option value="51">Sales</option>
                 <option value="52">Services</option>
                 <option value="53">Parts</option>
                 <option value="FI">F&amp;I</option>
               </select>
             </label>
             <span class="selectRequiredMsg">Required</span></span></td>
           <td colspan="2" align="right"><label> Mananger:
             <input name="mananger" onclick="return getfoc()" type="text" id="mananger" size="12" readonly />
           </label></td>
         </tr>
         <tr>
           <td></td>
           <td>Store: <span id="spryselect6">
             <label>
               <select name="store" id="store">
                 <option disabled="disabled" selected="selected">Select One</option>
                 <option value="chevy">Chevy</option>
                 <option value="Ford">Ford</option>
                 <option value="Dodge">Dodge</option>
               </select>
             </label>
             <span class="selectRequiredMsg">Required</span></span></td>
           <td colspan="2" align="right"><div id="btn"> </div>
             <script language='javascript' type='text/javascript'>

    function GetValueFromChild(myVal)

    {

document.getElementById('mananger').value = myVal;
document.getElementById('btn').innerHTML = '<input type="submit" id="register" value="Print Ticket" />';


    }

             </script></td>
         </tr>
</tbody>
</table>
     <p>&nbsp;</p>
 </form>

答案 1 :(得分:1)

Format(TimeValue(Now), "hh:mm AM/PM").

将上午/下午更改为上午/下午 - A / P更改为a / p。用于小写 - 大写显示。