timedate format in excel vba
Posted on 2004-10-18
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???