hey guys
Can I have a feild of type date/time as a key for a table, where I can enter multiple values for the same date but different time? I know Access store time with date, but how to minipulate it.
sounds as though you are using a time stamp as a key field.
Am I right?
if so you can make the default value of the field
=now()
which puts the current date and time in the field.
which is ok unless you are super fast at entering data.
ho ho ho.
I've used this method and have no problems with it.
Ian Mayor (UK) Program Error
Programming is 1% coding, 50% error checking and 49% sweat as your application bombs out in front of the client.
hi
actualy, the table key is compond key(a:number,d:date) and there is a need to have multiple row at the same date, so I was thinking time makes it unique?
The following code demonstrates a few things. Like you said regardless of the format all dates have both a time portion and a date portion. The date is stored as the amount of days since 12/30/1899. The time is stored as the amount of seconds since midnight.
Date() - returns the date with the time portion set 0 which equals to 12:00 AM
Now() - returns current date and time
A date supplied only a time portion defaults to 0 days past 12/30/1899
Public Sub datetest()
Dim x As Date
x = Date
Debug.Print TimeValue(x)
Debug.Print DateValue(x)
x = Now
Debug.Print TimeValue(x)
Debug.Print DateValue(x)
x = CDate("4:00:00 pm")
Debug.Print TimeValue(x)
Debug.Print DateValue(x) + 1
End Sub
If what you want is a compound key, why not just use a compound key? In the table's design view, select both fields you want, then press the "Key" symbol on the toolbar.
Guys
Thnks so much. I beleive I am not explaining my case.
Majp, what you said is very nice.
adalger: I do have a table with compond key, number and date, but access won't let me insert recors like:
no(integer) e_date(date)
--- ----
1 6-15-2006
1 6-15-2006
1 6-15-2006
I want to enable the time within the e_date that the 3 records up are different. I am looking for a unique key for something like that.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.