Date/Time issue , Urgent plz (1 Viewer)

Ossama22

Registered User.
Local time
Tomorrow, 01:09
Joined
Aug 31, 2018
Messages
52
Hello guys ,

I need your help with " how can i show time in a Date/Time format cell , i tried alot of soultions i found on internet , like make the default value = NOW() , and set "Never" in show date picker , but it's useless , so i have a form linked with query and table , i just wanna to show time beside the date ( the actual time of modified not the current time ) is that possible by anyway !

Thx guys
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:09
Joined
Sep 21, 2011
Messages
14,048
Use the general format for the control?, that will show date and time, providing you have placed a time element in the field.
 

Ossama22

Registered User.
Local time
Tomorrow, 01:09
Joined
Aug 31, 2018
Messages
52
Use the general format for the control?, that will show date and time, providing you have placed a time element in the field.

i tried that , its only show date , not time .
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:09
Joined
Sep 21, 2011
Messages
14,048
So that means the time is 00:00:00 and you have just been putting date in the field.
Update it with NOW() in a query and then view it.
I have just done that in a Date/Time field which was only holding a date and I got 11/09/2018 21:16:45

HTH
 

Ossama22

Registered User.
Local time
Tomorrow, 01:09
Joined
Aug 31, 2018
Messages
52
So that means the time is 00:00:00 and you have just been putting date in the field.
Update it with NOW() in a query and then view it.
I have just done that in a Date/Time field which was only holding a date and I got 11/09/2018 21:16:45

HTH

Did you mean i should use build a expression in this cell in query ! it's named PTS Date , may i press build and make it PTS Date = NOW() ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:09
Joined
Sep 21, 2011
Messages
14,048
No, you need the time element in the field that you want to show the date and time for.

So if you were updating a field on the table for modified, you would use NOW().
That would put not only the date but the time as well, and then with the general format you will get to see both. If only a date element exists and not time element, Access will just show the date.

What I was trying to explain, was that I took a field that only had the date element and updated one record with NOW() to see what it would show on the form, and it then showed the date and the time element, as I believe you want.?
 

Ossama22

Registered User.
Local time
Tomorrow, 01:09
Joined
Aug 31, 2018
Messages
52
No, you need the time element in the field that you want to show the date and time for.

So if you were updating a field on the table for modified, you would use NOW().
That would put not only the date but the time as well, and then with the general format you will get to see both. If only a date element exists and not time element, Access will just show the date.

What I was trying to explain, was that I took a field that only had the date element and updated one record with NOW() to see what it would show on the form, and it then showed the date and the time element, as I believe you want.?

Yeah that's excatly what i want to do , showing both of date and time , but please excuse my little knowledege in access , could you tell me where should i write "Now()" iam now in design veiw for my table . should i write it in a default value or which place ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:09
Joined
Sep 21, 2011
Messages
14,048
Yes, you could put the NOW() as the default date/time in the table for when a record was created, but you need to update the record if it ever gets modified.?

Here is a way I was shown how to do it. I use this rather than the default in the table.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
    Me.CreatedDate = Now()
    Me.CreatedBy = Environ("username")
Else
    Me.AmendedDate = Now()
    Me.AmendedBy = Environ("username")
End If
End Sub
 

Ossama22

Registered User.
Local time
Tomorrow, 01:09
Joined
Aug 31, 2018
Messages
52
Yes, you could put the NOW() as the default date/time in the table for when a record was created, but you need to update the record if it ever gets modified.?

Here is a way I was shown how to do it. I use this rather than the default in the table.
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
    Me.CreatedDate = Now()
    Me.CreatedBy = Environ("username")
Else
    Me.AmendedDate = Now()
    Me.AmendedBy = Environ("username")
End If
End Sub

I really appriciate tour contionous support , and iam sorry for being annoying , but as per my info your code is only for adding a new record (maybe iam wrong) , lemme explain to you , i already have my data i search for ID using combo box when then i put a date in (PTS Date-Attached) all i need is when i put this date it shows time too , so could you gimme the updated code with my table cells not urs (should i replace created date with PTS date ) but what about created by . i attach photos , maybe it could explain more . iam sorry again for being annoying TABLE DESIGN V.jpg

PTS FORM.jpg
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:09
Joined
Sep 21, 2011
Messages
14,048
Only you know what you want.?
That code I show sets the created date & time when a record is created as well as the name of the user who created it.
If it is not a new record, it updates an amended field with the current date and time of the amendment again as well as the username.

From your description, it sounds like you should be putting NOW() in PTS Date-Attached
If in a form you can use the same key strokes as excel, though a button might be easier.

https://support.office.com/en-us/article/insert-the-current-date-and-time-in-a-cell-b5663451-10b0-40ab-9e71-6b0ce5768138
 

Users who are viewing this thread

Top Bottom