'********************************************************************

'*

'* Function GetCurrentDateTime

'*

'*   Author: NetworkAdminKB.com

'*  Created: 2006-01-11

'* Modified: 2006-01-11

'*

'* Purpose: Returns the Current Date and/or Time.

'*

'*   Input: intFormat  An integer reprsenting the format to return the

'*                       Date/Time in.

'*    Value    Description

'*      0      Display the current date and time. (Default)

'*               Example: 8/22/2006 11:19:16 AM

'*      1      Display the current date using the long date format specified

'*               in your computer's regional settings.

'*               Example: Tuesday, August 22, 2006

'*      2      Display the current date using the short date format specified

'*               in your computer's regional settings.

'*               Example: 8/22/2006

'*      3      Display the current time using the time format specified in

'*               your computer's regional settings.

'*               Example: 11:19:16 AM

'*      4      Display the current time using the 24-hour format (hh:mm only,

'*               no seconds) Example: 11:19

'*             Display the current Date and Time in one of the following

'*               Date and Time Formats.

'*      5      YYYY/MM/DD HH:MM:SS ?M (12h Time Format)

'*      6      YYYY/MM/DD HH:MM:SS    (24h Time Format)

'*      7      YYYY-MM-DD HH:MM:SS ?M (12h Time Format)

'*      8      YYYY-MM-DD HH:MM:SS    (24h ISO 8601 Format)

'*             Display the current Date in one of the following

'*               Date Formats.

'*      9      YYYY/MM/DD

'*     10      YYYY-MM-DD

'*             Display the current Time in 24 Hour Time format with Seconds)

'*     11      HH:MM:SS    (24h Time Format)

'*

'*  Output: Returns the Current Date and/or Time.

'*

'*   Notes:

'*

'* Calls:

'*   DateTimeFormat

'********************************************************************

Function GetCurrentDateTime(ByVal intFormat)

   'Version: 1.0 2006-01-11

   If IsEmpty(intFormat) Then intFormat = 0

  

   If intFormat < 0 Or intFormat > 11 Then intFormat = 0

  

   Select Case intFormat

     Case 1,4

       GetCurrentDateTime = FormatDateTime(Now, intFormat)

     Case 0,2,3

       GetCurrentDateTime = CDate(FormatDateTime(Now, intFormat))

     Case 5,6,7,8

       GetCurrentDateTime = DateTimeFormat(Now, intFormat - 4)

     Case 9

       GetCurrentDateTime = DateTimeFormat(Date, 1)

     Case 10

       GetCurrentDateTime = DateTimeFormat(Date, 3)

     Case 11

       GetCurrentDateTime = DateTimeFormat(Time, 2)

   End Select 'intFormat

End Function 'GetCurrentDateTime

Article ID: 394, Created On: 9/25/2011, Modified: 9/25/2011