Default Value Time() question

S

Silvio

I am using Time() as default value for my date/time control. However, the
system stores the full time, meaning hour, minute and seconds. How can I get
it to "store only" the hour and minutes? (e.g. 15:32 and not 15:32:36)

Thank you folks
 
J

Jeff Boyce

You can't. A date/time value is stored as a date/time value.

However, you CAN get Access to DISPLAY only the hhnn portion. Take a look
at "Format" in Access HELP.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
C

Clifford Bass

Hi Silvio,

As Jeff said you cannot not store the seconds. But you can get it to
default to just hours and minutes with zero seconds:

For hour/minute just past:

TimeSerial(Hour(Time()),Minute(Time()),0)

For nearest hour/minute:

TimeSerial(Hour(Time()),Minute(Time())+IIf(Minute(Time())>=30,1,0),0)

Hope that helps,

Clifford Bass
 
A

AccessVandal via AccessMonster.com

What's wrong with setting the table field/column format or the form's control
format to "hh:nn"?
 
C

Clifford Bass

Hi Silvio,

Why would that be depressing? Anyway, you are welcome.

Clifford Bass
 
C

Clifford Bass

Hi,

It would depend on the end goal. Is there going to be time math
involved later on? Then the presence of seconds could well make a
difference. For display purposes only? Nothing wrong there. Unless you
want the nearest minute.

My $0.02 worth,

Clifford Bass
 
S

Silvio

The challenge is that occasionally the user need to change the time before
saving the record. It becomes messy when you see only the date and time as
mm/dd/yyyy hh:mm and then when you click in it to change the time you get
extra item hh:mm:ss to fill in. I am afraid that they will start to change
the seconds instead of the minutes because of the visual effect.
 
A

AccessVandal via AccessMonster.com

A simple solution would be the Input Mask. In the Input Mask wizard, select
the Short Time "13:12".
This will prevent incorrect input and with the control's Validation Text, key
a message to inform the user of the correct format. And you can also create
your custom input mask if you like.
 

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

Top