cedop
asked on
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???
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???
format(datetime.now,"dd/mm /yyyy")
ASKER
that didn't work, got the error message
Compile Error:
Cant find project or library
with the word 'Format' highlighted
Compile Error:
Cant find project or library
with the word 'Format' highlighted
try vba.format
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.