Solved Date to DateTime (1 Viewer)

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:18
Joined
Feb 19, 2002
Messages
43,302
So here we go again ...
I don't think so. Your question was how to convert a date column to hold datetime which somehow took 18 responses before you got a non-ambiguous answer that you DO NOT need to convert anything. The problem being you asked the wrong question. Now that we know what the real question is (how can I also enter time when I enter the date in the calendar), we can give a definitive solution.

There are custom calendars that include a time option. Maybe you can search and find one or someone will post a link. OR build your own. I think @Uncle Gizmo has a date sample that might be expanded.

Here's some links I found:

The first one links to several free samples. I didn't test any and not all handle time.

The second two do handle time but they are not free.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 23:18
Joined
May 21, 2018
Messages
8,536
Here is an example time picker. I did not make a combine one, but this lets you add the time portion to a date (datetime) field.

AddTime.jpg
AddTime2.jpg

I added another time picker too!
 

Attachments

  • MajP Option Time Picker.accdb
    616 KB · Views: 72
  • Dial TimePicker.accdb
    524 KB · Views: 71

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 23:18
Joined
May 21, 2018
Messages
8,536
If desired I can combine this with a calendar on to one popup.
 

AlexN

Registered User.
Local time
Today, 06:18
Joined
Nov 10, 2014
Messages
302
@MajP
Wonderful job MajP. Once again you show the way.
Still...
This will do for new records. For the existing ones problem remains. So I've been awfully wrong not only for the question asked, but in initial design as well, and yeah it's "here we go again..."
It's alright, I'm learning things :)
Thank you so much!!!
 

Gasman

Enthusiastic Amateur
Local time
Today, 04:18
Joined
Sep 21, 2011
Messages
14,317
This will do for new records. For the existing ones problem remains
Well as you cannot possible know the time for all the previous records, the situation is moot surely?
They just remain at 0:00:00
 

KitaYama

Well-known member
Local time
Today, 12:18
Joined
Jan 6, 2022
Messages
1,541
Well as you cannot possible know the time for all the previous records, the situation is moot surely?
They just remain at 0:00:00
I would use an update query and add 1 second to the field : DateAdd("s",1,fieldname)
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 23:18
Joined
May 21, 2018
Messages
8,536
This will do for new records. For the existing ones problem remains. So I've been awfully wrong not only for the question asked, but in initial design as well, and yeah it's "here we go again..."
As long as you understand it is only a Display problem and not a data or storage problem.
Even if the field has a format applied, 12:00:00 AM or 00:00:00 as part of the date will not display. It is there, just will not display. I prove this in my example where I simply add time to the existing field using my timepicker.
As said by @kitayam if it bothers you so much you have to see it, then have the default add 1 second to the date and get something 1/1/2023 00:00:01. I tried adding a fraction of a second hoping that would force the display, but it did not.

So I do not understand the "existing problem". There is no existing problem. All you existing records are valid they just have a time of 12:00:00 AM. You could do an update query to add one second to all the records.
Now be careful because it may break a lot of things.
if SomeField = SomeDate
Now that you add a time values as part of your datetimes it is highly unlikely that will return any records. Then you have to do something like
if int(someField) = int(someDate)
or
if SomeField => someDate and somefield < someDate + 1
 

AlexN

Registered User.
Local time
Today, 06:18
Joined
Nov 10, 2014
Messages
302
You guys are all wonderful,
@Gasman , you showed the way
@KitaYama , man you gave THE idea, that saved me from days of work!
@MajP , once again you've been so helpful!

So, I added one more field to my table, used the update query suggested to display time too, kept the "only date" one to maintain relationships, used the new field for all my calculations, and that was it. All systems go now. I'm happy again :ROFLMAO:.

To all people who got involved, thank you so much, you're teaching me a lot!
Case solved (once again).
 

Users who are viewing this thread

Top Bottom