FileDatetime Doesn't Include Time If File Time Is MidnightLast reviewed: June 21, 1995Article ID: Q96098 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0
SUMMARYPassing a file name with a time stamp of midnight to the function FileDateTime, returns a string containing only the date, not the time. This is consistent with the Format/Format$ function's General Date format, which when passed a DateTime string with a time of midnight returns a string containing only the date. If your program needs to display a DateTime string with midnight represented by 12:00 AM or 00:00 (in 24-hour format), use the Format($) functions to perform the necessary conversion. By using Format$ or Format with the time format symbols h, m, and s, you can cause the Format($) functions to include a time format for midnight. In the example below, a message box showing both the date and time of VB.EXE, which is midnight for version 2.0, is displayed with a time stamp.
MsgBox Format$(FileDateTime("VB.EXE"), "mm/dd/yy hh:mm AMPM") MORE INFORMATIONThe internal structure of a serial number is a double precision number. The integral portion represents the number of days since December 30, 1899 and the fractional portion represents the time as a fraction of a day. Midnight is the beginning of a day and therefore it's represented by the fraction zero. For example the serial number for 10/21/92 6:00 AM is represented by:
33898.25The date is 33898 days since 12/30/1899. The time is represented as one-fourth of the 24-hour day passed since midnight. One-fourth of 24 is exactly 6, so the time is 6 hours, 0 minutes, 0 seconds. Using the General Date format for a DateTime string without using a time in Format($), automatically returns a formatted string without a time portion. This is by design. Because both midnight and DateTime strings without a time are represented internally as the same number, the General Date format processes the strings identically.
Steps to Reproduce Problem
|
Additional reference words: 2.00 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |