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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate a field to format as a date field

Status
Not open for further replies.

eddmon

Programmer
Apr 2, 2002
10
US
Here's a monkey on my back. I have a MakeTable query that adds or subtracts a number of days from a date field if a condition is true, false, or null. This works fine. However, the new date fields in the Table come across as text fields and I have to manually convert the fields to Date fields to export as an EXCEL file to the end users.
Is there a way to convert the fields to Date fields by code?
 
How are you doing the subtraction? What version of Access are you using? I experimented with a make-table query in Access 2000. I just subtracted a number from the date (ie. [datefield]-3) and used IIF conditions based on a text field and a logical field, including the possibility of null values. In Access 2000 no matter what I did the new field was a date-time field, and it stayed a date field in Excel.
 
jennyd41: In one instance I have the field calculate a date from: IIf([Indicator]Is Null AND [DateField1] Is Not Null, [Datefield1]-5, [DateField2]+3). Like I said, this gives me the result I want, but in the MakeTable, the field is formated as text and not as a date field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top