Date type

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

How I can change the date type from
dd/mm/yyyy hh:mm:ss to [hh]:mm:ss

Thanks & Regards

Hassan
 
For example:
sub test()
Yourdate = 01/12/2007 22:00:01
YourHour = Format(Yourdate,"hh:mm:ss")
msgbox Yourdate
End sub
 
I think it would be better to add a "Time" style to your workbook,
instead of re-defining the "Date" style. Changing the style would be
confusing to other users, if you forward the workbook to them.

To add a new style to your workbook (instructions for Excel 2000):

1. Choose the Style command from the Format menu.
2. Type in "Time" in the "Style name" combo box.
3. Uncheck all of the checkboxes except "Number".
4. Click the Add button.
5. Click the Modify button to display the Format Cells dialog box, then
choose "Time" in the Category list box, and one of the time formats in
the Type list box.
6. Click OK in the Format Cells dialog box.
7. Click Close or OK in the Style dialog box.

Use this "Time" style to format all of the cells you want. If you don't
have the style combo box displayed on your Formatting toolbar, add it by
using the Customize feature. (Microsoft started leaving the Style box
off of the toolbar with Excel 2000. I don't know if they have added it
back in more recent versions or not. Maybe Styles have even gone away in
the latest version!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top