• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

timedate format in excel vba

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
cedop
Asked:
cedop
  • 5
1 Solution
 
Mikal613Commented:
format(datetime.now,"dd/mm/yyyy")
0
 
cedopAuthor Commented:
that didn't work, got the error message

Compile Error:
Cant find project or library

with the word 'Format' highlighted
0
 
Mikal613Commented:
try vba.format
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Mikal613Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now