Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove seconds from Time()

Status
Not open for further replies.

aw23

Programmer
Nov 26, 2003
544
IL
I have a txtbox with the time in it as the default and the user can edit it. It currently has the hour, min, sec. Is there a way to get rid of the seconds so that the user doesn't see it?

Thanks
 
Set the format of the text box to be Short Time.

This will display just hours and minutes, in 24-hour format. If the user types a time which includes seconds, Access will remove these, e.g. 12:01:20 will be displayed as 12:01.

For a bound field, set the format of the underlying table column to be 'short time' as well. This will make sure that the time is always stored and displayed as hours and minutes only.


Bob Stubbs
 
Thanks I already have short time. The problem is that it displays only hours and minutes but when the user clicks on it to modify the seconds pop up. My users are finding this to be very annoying.
I tried hh:mm but it just changed it to short time. Is there anything I can do?

Thanks
 
I checked in my test form, and I found the same problem if the underlying table data contains seconds information. To achieve the 'hours and minutes only' effect, you need to:

-- Set short time as the format for the bound column in the table
-- set short time format for the field on the form
-- make sure there is no existing data in the table which contains seconds values. You could use an update query to force the existing data to hh:mm format, e.g.

update [MyTimeField] to:

format$([MyTimeField], "hh:mm")

When I did all three steps, I saw hours and minutes only.


Bob Stubbs
 
Thanks, but it's not bound to any table. I use it to set a reminder in Outlook.
 
OK, I got it. I set the default time to
Format(Time(),"Short Time")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top