Re: Date and Time query
- From: "John Spencer" <spencer@xxxxxxxxx>
- Date: Wed, 16 Aug 2006 16:58:44 -0400
Then you should be able to use an update query to populate the new fields
UPDATE YourTable
SET NewDateField = DateValue([DateTime]),
NewTimeField = TimeValue([DateTime])
WHERE IsDate([DateTime]) = True
It would probably be better to do this into one new field
UPDATE YourTable
SET NewDateTimeField = CDate([DateTime]),
WHERE IsDate([DateTime]) = True
You can then use the format function or the format property on controls to
force the display of the data in any manner you wish.
"Monsignor JAV" <jonvillalva@xxxxxxxxx> wrote in message
news:1155754828.343926.177700@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am storing the field types in datetime form.
John Spencer wrote:
You have not told us what the field types are? Are you attempting to
store
the date in a text field or a datetime field? Same thing for the time?
Format(TimeValue("7/27/2005 1:00:00 PM"),"hh:nn:ss") returns a string
that
is 13:00:00
Format(DateValue("7/27/2005 1:00:00 pM"),"yyyymmdd") returns a string of
20050727
Format(DateValue([DateTime]),"yyyymmdd") should work to give you a string
in
the format you want.
You are probably better off just storing the [DateTime] field into a
datetime field and then using formats to control the display of the
value.
Look up help on IsDate, CDate, TimeValue, DateValue, and the Format
function.
"Monsignor JAV" <jonvillalva@xxxxxxxxx> wrote in message
news:1155744829.513015.275250@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,
I have imported several thousand lines of data from comma separated
files to a temp import table. In the comma separated values the date
and time of the sample are included in the same field. I need to
extract the date and time to another table but into separate fields and
in a different format than originally imported in from. The date and
time is in a field called [DateTime] as seen below.
7/27/2005 12:00:00 PM
I need to separate the date into the format, yyyymmdd, and the time
into 24 hour format, hhnn using an append query to another table I have
created for storage.
I have tried to use the DatePart in conjunction with the format
operator with no luck. I have also attempted queries using the
DateValue, TimeValue, and Cdate all to no avail. I have tried to do
assemble the query breaking it up in parts just doing the Date part
first but nothing seems to work. Can someone please point me in the
right direction since I only get an invalid expression error or
notification that a parenthesis is not closed. Any help would be
wonderful.
Thanks!
Jon
.
- References:
- Date and Time query
- From: Monsignor JAV
- Re: Date and Time query
- From: John Spencer
- Re: Date and Time query
- From: Monsignor JAV
- Date and Time query
- Prev by Date: RE: Vacation Query
- Next by Date: Re: how to do this query
- Previous by thread: Re: Date and Time query
- Next by thread: Re: Date and Time query
- Index(es):
Relevant Pages
|