Copy link to clipboard
Copied
How do you get a date and a datetime type into a table with cfqueryparam ?
For date I have tried <cfqueryparam value=#createodbcdate(thedate)# cfsqltype="CF_SQL_DATE" maxlength="23" null="yes"> and got NULL in the table.
For time I tried <cfqueryparam value=#now()# cfsqltype="CF_SQL_TIME" maxlength="23" null="yes"> but the date part of the datetime value was 1970-01-01.
In the table, types for these columns are datetime.
As the name implies, cf_sql_date only inserts the date. Any time value is truncated. To insert both date and time use cf_sql_timestamp.
For date I have tried <cfqueryparam
value=#createodbcdate(thedate)# cfsqltype="CF_SQL_DATE"
maxlength="23" null="yes"> and got NULL in the table.
That is what null="yes" means. It instructs CF to ignore the "value" and insert a NULL instead. Only use it if that is the desired result.
Copy link to clipboard
Copied
As the name implies, cf_sql_date only inserts the date. Any time value is truncated. To insert both date and time use cf_sql_timestamp.
For date I have tried <cfqueryparam
value=#createodbcdate(thedate)# cfsqltype="CF_SQL_DATE"
maxlength="23" null="yes"> and got NULL in the table.
That is what null="yes" means. It instructs CF to ignore the "value" and insert a NULL instead. Only use it if that is the desired result.
Copy link to clipboard
Copied
Thank you. Hope no more questions for this.