Solved

timedate format in excel vba

Posted on 2004-10-18
6
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 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