Question: I am building a table in MS Access using SQL, one of the columns has a duration in days. I understand that if I build a new table with a *Make Table Query*, the column format properties just have to be set to @"days". Is there a way to do this in the code?

```vb
Dim tbl As String

tbl = "SELECT [Table1].[Task], [Table1].[Duration], [Table1].[Date] " & _
      "INTO [" & all & "] " & _
      "FROM [Table1]"

DoCmd.RunSQL tbl

```

When this code runs the new table converts *Duration* field to dates. 
For Clarity: *all* is a variable name for the new table.

Thank you!!!

Answer: 
You can do with DAO. Open the TableDef and set the *Format* property of the duration field.

But you wouldn't have to. To view the data, create a query or form to view the data, and apply the format to the field or textbox displaying the duration.

Or create a query for the export:

```
Select *, Format([Duration], '0') & ' days' As Days
From YourTable

```

or even:

```
Select *, Format([Duration], '0') & ' day' & IIf([Duration] = 1, "", "s") As Days
From YourTable

```
Have you tried something like; 

```
Sub Format_Dates()
     Selection.NumberFormat = "[$-en-US]d-mmm-yy;@"
End Sub

```

"Selection" can be replaced by Range.NumberFormat. 

(You would just need to find the date format you need. PowerSpreadsheets has a good article on this [found here "Excel VBA Date Format"](https://powerspreadsheets.com/vba-format-date/))