Changing the default hour and day function format

Posted on 2006-11-21
Last Modified: 2010-04-30

I never use VB but I am looking at a DTS script that looks for the hour and day and second to have the leading 0.

so 9am on 1/1/2006 should be 0900 01012006

Here are the current functions:

the hh, mon, da and min needs to be updated.

mydate =now()

Question by:sjsharp80
LVL 67

Accepted Solution

sirbounty earned 500 total points
ID: 17986639
mydate = Now()
hh = LZ(Hour(Time))
Min = LZ(Minute(Time))
yy = Year(Date)
mon = LZ(Month(Date))
da = LZ(DatePart("d", Date))

Here's the function:
Function LZ(str)
  LZ = str
  If (str >= 0) And (str < 10) Then LZ = "0" & str
End Function

Author Comment

ID: 17986775
Perfect, thanks

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now