VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Keeps SQL NULL Dates NULL instead of defaulting to 1/1/1900 - using SQL string - also avoid errors

by Patrick JJ Kavanagh (2 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 17th March 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Keeps SQL NULL Dates NULL instead of defaulting to 1/1/1900 - using SQL string - also avoid errors with different date formats - SQL loves

API Declarations


' and a field called mydate in a table called mytable

Rate Keeps SQL NULL Dates NULL instead of defaulting to 1/1/1900 - using SQL string - also avoid errors



strSQL = "UPDATE mytable SET " & _
         IIf(Len(strDateField) > 0, _
             "mydate = " & format(cdate(strDateField), "yyyy-mm-dd"), _
             "mydate = " & "NULL")


Download this snippet    Add to My Saved Code

Keeps SQL NULL Dates NULL instead of defaulting to 1/1/1900 - using SQL string - also avoid errors Comments

No comments have been posted about Keeps SQL NULL Dates NULL instead of defaulting to 1/1/1900 - using SQL string - also avoid errors . Why not be the first to post a comment about Keeps SQL NULL Dates NULL instead of defaulting to 1/1/1900 - using SQL string - also avoid errors .

Post your comment

Subject:
Message:
0/1000 characters