Solved

timedate format in excel vba

Posted on 2004-10-18
6
183 Views
Last Modified: 2008-02-01
Hi all,

I need to format a string in a vba userform.

what i have is:

    TextBox1.Value = DateTime.Now - 2
    TextBox2.Value = DateTime.Now - 1

this gives me the dates in the forrmat  mm/dd/yyyy hh:mm:ss AM/PM
I need the format dd/mm/yyyy only. can someone tell me how to reformat this.

I tried doing

dim date1 = timedate.now
dim day1 = date1.day
dim month1 = date1.month
dim year1 = date1.year
dim d1 = day1 & "/" & month1 & "/" & year1

as well as trying date1.toString("dd/mm/yyyy")

can someone tell me where I'm going wrong???
0
Comment
Question by:cedop
  • 5
6 Comments
 
LVL 48

Expert Comment

by:Mikal613
ID: 12343781
format(datetime.now,"dd/mm/yyyy")
0
 

Author Comment

by:cedop
ID: 12343923
that didn't work, got the error message

Compile Error:
Cant find project or library

with the word 'Format' highlighted
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12343934
try vba.format
0
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.

 
LVL 48

Expert Comment

by:Mikal613
ID: 12343935
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 12343956
0
 
LVL 48

Accepted Solution

by:
Mikal613 earned 125 total points
ID: 12343975
HERE

go into the VB editor

then select Tools/References

have a look for any that are missing (its says MISSING)

then make a note of these, then uncheck, click ok to get out of references, then go back in again and find those references (might be on list or you need to browse thru it)
If it is a third party you may need to get hold of that file again (and reference it in here)

also - do a debug/compile in the code

;)
0

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

911 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

25 Experts available now in Live!

Get 1:1 Help Now