Share via

Appending Date Data from Access to SQL Server but some fields are NULL and Causing Error Box

Anonymous
2023-09-26T14:08:31+00:00

I have created an append query in Access (Office 365) to append among other things date data to a table in a SQL Server but it gives me an error (Type Conversion Failure) when "sending" NULL's.

I have tried the following, all of which send the dates data to SQLServ but doesn't like the NULL:

Status_Date_New: IIf(IsNull([StatusDate])=True,"Null",[StatusDate])

Status_Date_New: IIf(IsNull([StatusDate])=True,"",[StatusDate])

Status_Date_New: Format(NZ([StatusDate], '1900-01-01 00:00:00:000', [StatusDate])

Status_Date_New: NZ(Format([StatusDate], "yyyy/mm/dd hh:nn:ss"), '1900-01-01 00:00:00:000')

Status_Date_New: NZ([StatusDate],"NULL",[StatusDate])

Just variations on a theme I could go on with the things I have tried but I didn't write all of them down, thought maybe one of you smart people had something that works.

Microsoft 365 and Office | Access | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

9 answers

Sort by: Most helpful
  1. Anonymous
    2023-09-26T15:45:09+00:00

    SQLServer = datetime

    Access = Date/Time

    Was this answer helpful?

    0 comments No comments
  2. Duane Hookom 26,825 Reputation points Volunteer Moderator
    2023-09-26T15:38:22+00:00

    The source data might contain a zero length string or a space in the StatusDate field. I would spend some time exploring the source data and maybe try a subset of the records.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2023-09-26T15:32:05+00:00

    Then it's obviously a problem with data types.

    What is the data type of the field in the source table?

    What is the data type of the field in the destination table?

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2023-09-26T14:43:48+00:00

    Just sending the field creates the error as well, that's what got me down the rabbit hole. I'm just showing you everything I have tried up to this point, I'm not saying those should have worked.

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2023-09-26T14:36:55+00:00

    If your are appending to a date type field, then you don't need an IIf statement, just append your StatusDate field.

    Your IIf statement is trying to append the string value of 'NULL', That is not the same as an actual NULL.

    Was this answer helpful?

    0 comments No comments