Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date/Time data type

Status
Not open for further replies.

adwanoy

MIS
Apr 10, 2006
37
US
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.
 
What is your problem manipulating DateTime values ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
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

12:00:00 AM
6/15/2006

8:07:15 AM
6/15/2006

4:00:00 PM
12/31/1899
 
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.

TMTOWDI - it's not just for Perl any more
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top