ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date type (https://www.excelbanter.com/excel-programming/396950-date-type.html)

Hassan

Date type
 
Hi All,

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

Thanks & Regards

Hassan

Halim

Date type
 
For example:
sub test()
Yourdate = 01/12/2007 22:00:01
YourHour = Format(Yourdate,"hh:mm:ss")
msgbox Yourdate
End sub
--
Regards,

Halim



"Hassan" wrote:

Hi All,

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

Thanks & Regards

Hassan


Bill Renaud

Date type
 
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!)
--
Regards,
Bill Renaud





All times are GMT +1. The time now is 11:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com