Need to put date in table

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

Hi All,

I have a Table which has no date field in and I need to append MealName,
ItemName and Qty to a table Meal Defines. I also need to put a date in Meal
Defines with each. How do I do that. The following SQL is working and I am
manually inserting the date:

INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal )
SELECT FoodItems.ItemName, FoodItems.Quantity, FoodItems.MealName
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

I know there is a easy way to do this, but escapes me.

TIA
 
More details are probably needed. What date values do you need to insert?
Are all the values the same date when you run the query?

INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal , [SomeDateField])
SELECT FoodItems.ItemName
, FoodItems.Quantity
, FoodItems.MealName
, Date()
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

Or perhaps
INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal , [SomeDateField])
SELECT FoodItems.ItemName
, FoodItems.Quantity
, FoodItems.MealName
, CDate([For which date?])
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Hi All,

I have a Table which has no date field in and I need to append MealName,
ItemName and Qty to a table Meal Defines. I also need to put a date in Meal
Defines with each. How do I do that. The following SQL is working and I am
manually inserting the date:

INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal )
SELECT FoodItems.ItemName, FoodItems.Quantity, FoodItems.MealName
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

I know there is a easy way to do this, but escapes me.

TIA

If you want today's date, just include the Date() function in the query:

INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal, Mealdate)
SELECT FoodItems.ItemName, FoodItems.Quantity, FoodItems.MealName, Date()
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

John W. Vinson [MVP]
 
I am Certainly going to try your ideas. What I am Looking for is:

1. I run the query
2. It will ask me for the date.
3. The query will run inserting the date, [Food Name],
Quantity, the Meal.


Let me try. Will be right back

--
Ron


John W. Vinson said:
Hi All,

I have a Table which has no date field in and I need to append MealName,
ItemName and Qty to a table Meal Defines. I also need to put a date in Meal
Defines with each. How do I do that. The following SQL is working and I am
manually inserting the date:

INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal )
SELECT FoodItems.ItemName, FoodItems.Quantity, FoodItems.MealName
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

I know there is a easy way to do this, but escapes me.

TIA

If you want today's date, just include the Date() function in the query:

INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal, Mealdate)
SELECT FoodItems.ItemName, FoodItems.Quantity, FoodItems.MealName, Date()
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

John W. Vinson [MVP]
 
Gentlemen let me Thank You.
It was so simple.
This is the query I used;
INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal , MealDate )
SELECT FoodItems.ItemName
, FoodItems.Quantity
, FoodItems.MealName
, Date()
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

And it worked fine. After I looked at the query pane I was embarrassed!!

Thanks again guys. . . .I'm Glad You're Here
--
Ron


John Spencer said:
More details are probably needed. What date values do you need to insert?
Are all the values the same date when you run the query?

INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal , [SomeDateField])
SELECT FoodItems.ItemName
, FoodItems.Quantity
, FoodItems.MealName
, Date()
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

Or perhaps
INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal , [SomeDateField])
SELECT FoodItems.ItemName
, FoodItems.Quantity
, FoodItems.MealName
, CDate([For which date?])
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Ron said:
Hi All,

I have a Table which has no date field in and I need to append MealName,
ItemName and Qty to a table Meal Defines. I also need to put a date in
Meal
Defines with each. How do I do that. The following SQL is working and I
am
manually inserting the date:

INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal )
SELECT FoodItems.ItemName, FoodItems.Quantity, FoodItems.MealName
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

I know there is a easy way to do this, but escapes me.

TIA
 
Hi All,

I have a Table which has no date field in and I need to append MealName,
ItemName and Qty to a table Meal Defines. I also need to put a date in Meal
Defines with each. How do I do that. The following SQL is working and I am
manually inserting the date:

INSERT INTO [Meals Defines] ( [Food Name], Quantity, Meal )
SELECT FoodItems.ItemName, FoodItems.Quantity, FoodItems.MealName
FROM FoodItems
WHERE (((FoodItems.Use)=Yes));

I know there is a easy way to do this, but escapes me.

TIA

Why are you *RUNNING* this append query at all, rather than simply using a
bound form? In the latter you could have a textbox bound to MealDate with a
default value of =Date().

John W. Vinson [MVP]
 
Back
Top