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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

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
 

Forum statistics

Threads
1,141,027
Messages
5,703,818
Members
421,318
Latest member
cg_cartoonexcel

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
Top