Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Empty Fields formated for Date

Status
Not open for further replies.

CptCrusty1

Programmer
Feb 17, 2005
216
US
I'm trying to tune someone elses work (doesn't work here anymore) and they have 2 queries which add fields. In the past, I've added a field, calculated fied, etc., by using "FIELD:X+Y" or something like that. What I'd like to do is add two extra fields, which will be populated by later processes. The fields would be a number and date fields. I could just create a table with the fields, then clear the contents of the table before repopulating it, but I'm being stubborn... :)

Crusty


I live to work and I work to live.
 
Can you clarify?

Do you want to add these fields to a Table or to a Query?

Upon reflection, I guess it must be a table because an empty fields in a query have no type until you actually put data in them.

Try this
Code:
ALTER TABLE myTable ADD COLUMN NewColumn1 Date;
ALTER TABLE myTable ADD COLUMN NewColumn2 Long;

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
I alread have code like that, it means I have to add an extra step which I'm trying to avoid. I'm trying to trim the fat on this process to speed it up as much as possible. I need to do this in the original Make Table query:

Select A,B,C as Fieldname, D as Fieldname
Into Table1

From X
Where X.A is yadda, B is yadda, etc, etc..

Thats easy, but I need to have formatting in place inside the query.


I live to work and I work to live.
 
You can do things like
Code:
Select A, B, C, NULL As TheDateField INTO NewTable ...
But that will create a new field with a Binary datatype. If you want to force a datetime field then you need to load it with a datetime value.
Code:
Select A, B, C, Date() As TheDateField INTO NewTable ...


[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top