Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a database with a column that displays a date and time.
EG: 1/7/2006 5:15 PM
I want to extract the time out of this column and create a new column.
Leaving just the date in the original column.
 
In your query make a new field that refers to your date/time field.

If your date/time is called [DateTime] your new field will be called
[time]. Format the 1st as Date and the 2nd as Time.

If you are working in a query this is done in properties if on a form it is
done in format

Hope this helps
 
On Wed, 8 Feb 2006 08:30:17 -0800, "health nut" <health
I have a database with a column that displays a date and time.
EG: 1/7/2006 5:15 PM
I want to extract the time out of this column and create a new column.
Leaving just the date in the original column.

Why?

Storing the date and time redundantly, or even separately, is probably
a Bad Idea.

You can create a Query based on your table with two calculated fields:

JustDate: DateValue([fieldname])
JustTime: TimeValue([fieldname])

These will contain the date and time respectively, and can be used for
sorting, searching, etc. just as if they were table fields.

John W. Vinson[MVP]
 
<picky>
I'd suggest a different field name. Time is a reserved word, and shouldn't
be used.
</picky>

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Wayne-in-Manchester said:
In your query make a new field that refers to your date/time field.

If your date/time is called [DateTime] your new field will be called
[time]. Format the 1st as Date and the 2nd as Time.

If you are working in a query this is done in properties if on a form it is
done in format

Hope this helps


health nut said:
I have a database with a column that displays a date and time.
EG: 1/7/2006 5:15 PM
I want to extract the time out of this column and create a new column.
Leaving just the date in the original column.
 
That's a very bad idea. Trust me on this. But if you are bound and
determined....

UPDATE EMP
SET EMP.LAST_UPDATED = Format([EMP]![HIREDATE],"Short Time")
WHERE (((EMP.HIREDATE) Is Not Null));

Then

UPDATE EMP
SET EMP.LAST_UPDATED = Format([EMP]![HIREDATE],"Short Date")
WHERE (((EMP.HIREDATE) Is Not Null));

Some day you will regret it though.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top