How do I change a field's data type through VB?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BulbFresh
    New Member
    • Feb 2008
    • 10

    How do I change a field's data type through VB?

    Hi,

    I have imported some data to a table, one field is [Arrival Time] whose values are in the form "dd/mm/yyyy 00:00:00" however I would like to run a command (possibly just after importing the table) to change this field to the form "dd/mm/yyyy" or short date. This is so that I can later Group By [Arrival Time]

    In Access 2007 If I was in design view of my Table [January] i would make sure the Data Type is set to [Date/Time] and then under Field Properties the Format would be set to [Short Date]

    Basically I wondered if anyone knew the VB (or SQL) to do this.

    Thank you

    Chris
  • sierra7
    Recognized Expert Contributor
    • Sep 2007
    • 446

    #2
    Hi Chris
    I can't follow what you are using (is it SQL Server?) because you have implied it is not Access.

    Can you not enforce the required format during the import/append ?

    Access is quite forgiving and lets you change (some) data types after importing but when I have wanted to do something like this programmaticall y I have usually added a new column then run an UPDATE copying the the old to the new, just incase some data will not convert and I verify both. Once happy can delete the old then rename the new.

    S7

    Comment

    Working...