Date formating

Logistix

Board Regular
Joined
Aug 23, 2006
Messages
77
Hi,

I'm trying to only display the selected date (that i've selected in my DTPICKER1 calander userform), but it's also displaying todays time (in hours) directly after the date. Does anyone know how to format it correctly as when I try to it doesn't work.

Code:
Private Sub UserForm_Activate()
    
    EnterHours.DTPicker1.Value = Format(Date, "dddd, d mmmm yyyy")
    
    Me.Label3.Caption = "I " & EnterHours.EmployeeNameBox.Text & " will deposit " & EnterHours.HoursDepositBox.Text & " for " & EnterHours.DTPicker1.Value
    

End Sub

tks
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

sunnyland

Well-known Member
Joined
Jan 27, 2006
Messages
912
Hello,

In your code
Code:
Private Sub UserForm_Activate() 
EnterHours.DTPicker1.Value = Format(Date, "dddd, d mmmm yyyy") 
Me.Label3.Caption = "I " & EnterHours.EmployeeNameBox.Text & " will deposit " & EnterHours.HoursDepositBox.Text & " for " & EnterHours.DTPicker1.Value 
End Sub

You are trying to change the value of the dtpicker1 to today formatted date.

Then you try to displayed the formatted date.

If you want to display the value formatted then what you need to do is

EnterHours.DTPicker1.Value =date()
Me.Label3.Caption = "I " & EnterHours.EmployeeNameBox.Text & " will deposit " & EnterHours.HoursDepositBox.Text & " for " & Format(Enterhours.DTPicker1.Value, "dddd, d mmmm yyyy")

If you want the DTPicker to display in this format then use as follow[notice that using customformat with Dtpicker the month are M Uppercase as lower case means minutes] Lookup the help for dtpicker.

Enterhours.DTPicker1.Format = dtpCustom
Enterhours.DTPicker1.CustomFormat = "dddd, d MMMM yyyy"
Enterhours.DTPicker1.Value = Date
Me.Label3.Caption = "I " & EnterHours.EmployeeNameBox.Text & " will deposit " & EnterHours.HoursDepositBox.Text & " for " & Format(Enterhours.DTPicker1.Value, "dddd, d mmmm yyyy")
MsgBox DTPicker1.Value
 

Watch MrExcel Video

Forum statistics

Threads
1,113,992
Messages
5,545,375
Members
410,679
Latest member
rolandbianco
Top