I have an insert statement that inserts data from a form into a MS SQL table. One of the fields is a date. If the user leaves the date blank (perfectly acceptable) It inserts as 1/1/1900 rather than Null. To avoid that I am testing for no date input, then if blank it uses an insert statment that does not include the date. I would rather only have a single insert statement.
There must be a better way leave the date blank. Any Ideas?
<cfif #FORM.duedate# eq "">
<cfquery name="insertDATA2" datasource="MyDataSource">
INSERT INTO projects
(requestor)
VALUES
(
'#form.requestor#'
)
</cfquery>
<cfelse>
<cfquery name="insertDATA2" datasource="MyDataSource">
INSERT INTO projects
(requestor,duedate)
VALUES
(
'#form.requestor#',
'#form.duedate#'
)
</cfquery>
</cfif>
There must be a better way leave the date blank. Any Ideas?
<cfif #FORM.duedate# eq "">
<cfquery name="insertDATA2" datasource="MyDataSource">
INSERT INTO projects
(requestor)
VALUES
(
'#form.requestor#'
)
</cfquery>
<cfelse>
<cfquery name="insertDATA2" datasource="MyDataSource">
INSERT INTO projects
(requestor,duedate)
VALUES
(
'#form.requestor#',
'#form.duedate#'
)
</cfquery>
</cfif>