By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,326 Members | 2,873 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,326 IT Pros & Developers. It's quick & easy.

Insert date

P: n/a
Hi,

I would like to add the current date, and time if possible, to all records
in a query?

--
Kind Regards,
Customer Services
Blue Bell Trading
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a

Blue Bell Trading - Customer Services wrote:
Hi,

I would like to add the current date, and time if possible, to all records
in a query?

--
Kind Regards,
Customer Services
Blue Bell Trading


SELECT Stuff, CDate(Int(Now()) AS theDate, CDate(Now() - Int(Now())) AS
theTime FROM tblData;

James A. Fortune

Nov 13 '05 #2

P: n/a

jimfort...@compumarc.com wrote:
Blue Bell Trading - Customer Services wrote:
Hi,

I would like to add the current date, and time if possible, to all records
in a query?

--
Kind Regards,
Customer Services
Blue Bell Trading
SELECT Stuff, CDate(Int(Now()) AS theDate, CDate(Now() - Int(Now())) AS

^
|

) <--- Oops. Insert another ).
theTime FROM tblData;

James A. Fortune


Nov 13 '05 #3

P: n/a
<ji********@compumarc.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...

Blue Bell Trading - Customer Services wrote:
Hi,

I would like to add the current date, and time if possible, to all
records
in a query?


SELECT Stuff, CDate(Int(Now()) AS theDate, CDate(Now() - Int(Now())) AS
theTime FROM tblData;


If you're going to separate the date and time, why not

SELECT Stuff, Date() AS theDate, Time() AS theTime FROM tblData;

However, why would you separate the date and time? Having them as separate
fields makes querying more complicated. If you have occasion to use only the
date portion, or only the time portion, you can always use the DateValue and
TimeValue functions.

SELECT Stuff, Now() AS theDateTime FROM tblData;
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

Nov 13 '05 #4

P: n/a


Douglas J. Steele wrote:
SELECT Stuff, CDate(Int(Now()) AS theDate, CDate(Now() - Int(Now())) AS
theTime FROM tblData;


If you're going to separate the date and time, why not

SELECT Stuff, Date() AS theDate, Time() AS theTime FROM tblData;

However, why would you separate the date and time? Having them as separate
fields makes querying more complicated. If you have occasion to use only the
date portion, or only the time portion, you can always use the DateValue and
TimeValue functions.

SELECT Stuff, Now() AS theDateTime FROM tblData;
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


Using just Now() was my first thought, but the comma after date in the
original post seemed to indicate they wanted separate fields. Date()
and Time() as you show are obviously the easier way to do it if
separate fields are desired.

James A. Fortune

Nov 13 '05 #5

P: n/a
Jim,
You may want to take a look at Access' (VBA) Help on the "DateValue"
and "TimeValue" functions.

Nov 13 '05 #6

P: n/a


Chuck Grimsby wrote:
Jim,
You may want to take a look at Access' (VBA) Help on the "DateValue"
and "TimeValue" functions.


Thanks Chuck. I had never even looked at those functions before. It
was interesting reading.

James A. Fortune

Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.