How can the seconds be removed from a new record timestamp (1 Viewer)

Danick

Registered User.
Local time
Today, 05:12
Joined
Sep 23, 2008
Messages
351
I have a continuous form which has a current time stamp when creating a new record by setting the default value of a textbox field to Time(). The field is a Medium Time field and displays properly when the record is created. But if the user clicks the field to edit it, the Medium Time changes to Long Time displaying the seconds as well. Note that since I'm using a continuous form, I can not use the ActiveX Date / Time picker box.

Is there a way to be able to click this textbox field and allow changes in Medium Time format (no seconds)?
 

isladogs

MVP / VIP
Local time
Today, 10:12
Joined
Jan 14, 2017
Messages
18,216
The data is stored as a double number so that it contains the seconds no matter how you format it. When you click on the record, you see the full data. That's normal behaviour.
 

Danick

Registered User.
Local time
Today, 05:12
Joined
Sep 23, 2008
Messages
351
The data is stored as a double number so that it contains the seconds no matter how you format it. When you click on the record, you see the full data. That's normal behaviour.

OK - so are you saying that there is no way, or even a workaround, to get the time field to not show the seconds when editing?
 

isladogs

MVP / VIP
Local time
Today, 10:12
Joined
Jan 14, 2017
Messages
18,216
Perhaps someone will correct me but I don't believe so.
The same is true if you have a number field formatted to 2 d.p.
If you enter a value with say 4 d.p. Only 2 d.p will be shown but the whole record is displayed when clicked on.

If it's a huge issue, then as a work round, lock the control and have users enter data in another textbox. Then use an after update event to update the time in the 'real' control.
 

Mark_

Longboard on the internet
Local time
Today, 02:12
Joined
Sep 12, 2017
Messages
2,111
Is there a specific reason you want to prevent the seconds from being entered/edited? If so, you can always strip off or round the seconds after they make a change. I really can't see a good reason to not store the seconds if you are using a "Time", but hey, each business does have different rules.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:12
Joined
May 7, 2009
Messages
19,234
have you checkef your computer's Regional setting for time.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:12
Joined
May 21, 2018
Messages
8,527
What was stated above is not correct. If your time is entered without seconds then when you edit it the seconds will not appear (assuming medium or short time format). You can manually test this by deleting out your seconds. Adjust your default value to round up to nearest minute and you will not have a problem.
Code:
int(Time() * 24 * 60) / 24 / 60
 

missinglinq

AWF VIP
Local time
Today, 05:12
Joined
Jun 20, 2003
Messages
6,423
Are the times being used for anything other than simply displaying the time a new Record is created...such as for sorting the Records by creation time, or comparing the creation time with some other time?

If not, instead of using a Date/Time Field, you could use a simple Text Field and populate it like this:

Code:
Private Sub Form_Current()

If Me.NewRecord Then
  Me.TimeStamp = Format(Time, "hh:nn am/pm")
End If
 
End Sub
Linq ;0)>
 

Mark_

Longboard on the internet
Local time
Today, 02:12
Joined
Sep 12, 2017
Messages
2,111
MajP, per his original post, he is filling it with TIME() instead of a DATE() or NOW(), so all he is looking at is the time portion. Since TIME() returns seconds, he's always going to have seconds in the field unless he does something actively to remove them.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:12
Joined
May 21, 2018
Messages
8,527
Code:
MajP, per his original post, he is filling it with TIME() instead of a DATE() or NOW(), so all he is looking at is the time portion. Since TIME() returns seconds, he's always going to have seconds in the field unless he does something actively to remove them.
Read or try my post. If you put in 0 seconds for your time, you can come back and edit the time without it showing seconds. One more time. Change your default value from
Code:
Time()
to 
int(Time() * 24 * 60) / 24 / 60
As I said it works, as described.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:12
Joined
May 21, 2018
Messages
8,527
You can test this on your own without seconds. Create a date field and format to short date. Do an insert into the table of Now() and int(now()) or Date(). When you click into the field to edit the fields inserted as date you only get the date portion. If you click on the ones input into now (although formatted as short date) you will get a full date time back. That is the behavior that Ridder describes as the default behavior. Removing portion of the date/time defeats the default behavior.
 

Danick

Registered User.
Local time
Today, 05:12
Joined
Sep 23, 2008
Messages
351
What was stated above is not correct. If your time is entered without seconds then when you edit it the seconds will not appear (assuming medium or short time format). You can manually test this by deleting out your seconds. Adjust your default value to round up to nearest minute and you will not have a problem.
Code:
int(Time() * 24 * 60) / 24 / 60

WOW - this actually works!! Fantastic. Thank you so much. It's exactly what I was looking for.

For Mark - the reason I didn't want to see the seconds is only for the screen space and aesthetics. I need to make the box a little wider to accommodate for the seconds when editing the field. This is not that big a deal, but it also shifts a bit to show the seconds. Plus the seconds are really not needed for what I'm using it for, so if I'm glad I could get rid of them. And I did search the net looking for a solution to this before posting here and found numerous users with this same request but with no solution.

It's not a show stopper, but if it can be done, then why not. Thanks again!!
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 10:12
Joined
Jan 14, 2017
Messages
18,216
What was stated above is not correct. If your time is entered without seconds then when you edit it the seconds will not appear (assuming medium or short time format). You can manually test this by deleting out your seconds. Adjust your default value to round up to nearest minute and you will not have a problem.
Code:
int(Time() * 24 * 60) / 24 / 60

MajP
Congratulations on your solution to Danick's problem which is very neat

However, what I stated previously WAS and STILL IS correct.

The OP referred in post 1 to a default time being added to a record ...
current time stamp when creating a new record by setting the default value of a textbox field to Time()
in which case the seconds ARE displayed if you click on the record to edit it ... for the first time

If you use your code as the default value, the time is being SAVED as a different value in hh:mm. It is no longer the current time and no longer contains SECONDS.

Similarly, if you leave the default value blank and enter a value ...
OR if you go to edit a previously edited value where there is a default = Time(), the seconds do not reappear AS the saved value no longer contains SECONDS.

I hope that clarifies rather than confuses further
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 05:12
Joined
May 21, 2018
Messages
8,527
Totally confuses me, since you seem to be restating everything I have already stated. So not sure of your point, but with all the CAPITALIZATION you seem to be trying to emphasize something.

WAS and STILL IS correct.
Yeah I already said so.
n which case the seconds ARE displayed if you click on the record to edit it ... for the first time
If you click on the ones input into now (although formatted as short date) you will get a full date time back. That is the behavior that Ridder describes as the default behavior. Removing portion of the date/time defeats the default behavior.
 

isladogs

MVP / VIP
Local time
Today, 10:12
Joined
Jan 14, 2017
Messages
18,216
I started by quoting your post 7.
Later in post 11 you partly covered my point but without retracting your original comment.

So my post and capitalisation was indeed to emphasise the point I had originally made was correct.
 

Users who are viewing this thread

Top Bottom