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
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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
 
Upvote 0

Forum statistics

Threads
1,214,400
Messages
6,119,284
Members
448,885
Latest member
LokiSonic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top