473,396 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Insert date

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
6 4476

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

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
<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


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
Jim,
You may want to take a look at Access' (VBA) Help on the "DateValue"
and "TimeValue" functions.

Nov 13 '05 #6


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Bordas | last post by:
Hi list, I've got a little bug with MySQL. I can insert a row into my table but this row will not appear in the table :( Server is under linux redhat, MySQL is 3.23.56 installed from binary...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
2
by: kungfukittens | last post by:
Hi, question how do you insert from VB.net to a foxpro date field eg insert into temp values('07/31/05', 2) i keep getting a type mismatch error on the date field temp table date date no ...
9
by: cavassinif | last post by:
I need to dynamic select a column in which insert a vale based on a parameter value, I have this code, but it throws an incorrect syntax error. How do I dinamically select a column to insert...
1
by: albertleng | last post by:
Hi all... Can anyone give clue in doing below? Let say i have a table A with the following 3 fields. 1)Date 2)Title 3)Status. i need to insert into table B (also have the same 3 fields)...
3
by: assgar | last post by:
Hi I am having problem with my loping. I don't know if I have chosen the correct approach. GOAL: I need to insert into a table event types for a specific date range. The calendar the event...
0
by: gpspocket | last post by:
help me -CURSOR backward insert from End Date > to Start Date how to insert dates from end to start like this SELECT 111111,1,CONVERT(DATETIME, '17/03/2008', 103), CONVERT(DATETIME,...
0
BenRatcliffe
by: BenRatcliffe | last post by:
Hi there, I was wondering if anyone could help me. I have a comlpex database with a number of forms that have data entered on them and then saved into the correct table etc. In this instance I am...
0
by: Michael | last post by:
I know I am missing something simple, but I am stuck. When I submit the following for the employee info gets stored in scale1 and scale1 shows the employee number. Can someone show me my...
0
by: bgreer5050 | last post by:
I know I am missing something simple, but I am stuck. When I submit the following for the employee info gets stored in scale1 and scale1 shows the employee number. Can someone show me my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.