"Oliver Neumann" <ol************@newidentity.de> wrote in message
news:bm************@ID-130774.news.uni-berlin.de...
Hi There,
is there any possibility to declare datetime-column with special format in
ALTER TABLE-Statement.
e.g. I run the following query in MS-Access:
ALTER TABLE table ADD Datum DATETIME;
I get an add. column with datetime but NO "Format". I need to have "short"
format (xx.xx.xxxx),
but I cannot see any chance to alter my SQL-Query in order to get this
working. The problem is,
that I cannot use any of the access-tools to declare this column "short
format" 'cause I can only
use standard sql-queries to add this column.
Hope you can help!
ON
As Rick has pointed out, there isn't much point to adding the format
property - and this is why it isn't supported with the ALTER TABLE column.
However, if you really had to do this - for example, a customer looked at
the tables using Access, but couldn't work out how to do this on his own,
then I suppose you could write a small patch in vbs. Note you would have to
use DAO to get there.
Fletcher
Set eng = CreateObject("DAO.DBEngine.36")
Set dbs = eng.OpenDatabase("C:\Test\db1.mdb", True)
Set tdf = dbs.TableDefs("MyTable")
Set fld = tdf.CreateField("NewDateField", 8)
tdf.Fields.Append fld
Set prp = fld.CreateProperty("Format", 10, "ddd dd-mmm-yy")
fld.Properties.Append prp
Set prp = Nothing
Set fld = Nothing
Set tdf = Nothing
dbs.Close
Set dbs = Nothing
Set eng = Nothing
Msgbox "Done", vbInformation