 | 
October 3rd, 2008, 02:08 PM
| | Member | | Join Date: Mar 2007
Posts: 43
| | Change of date when using an UPDATE query in CF
Hi!
I have data returned from a database displayed on a webpage for amending.
A date on the form is selected using a pop-up calendar which returns it to Access. When the date is retrieved the dateFormat function is used to display it as dd/mm/yyyy.
However, when I run an update query, allowing the user to change any field and refind the record, the date is always changed to 30/12/1899.
Is there a problem with my update query?
update tblWorkshops
set WORecdate = #form.WORecdate#,
where ID = #ID#
I have not used createODBCdate(variable_Name) as I don't know where it needs to be created (ie on the cfm webpage or the action script that updates the database).
Thanks!
Neil
| 
October 3rd, 2008, 03:21 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 12,774
| |
Use cfqueryparam for the data input and set the CFSQLType attribute to use the CF_SQL_DATE type.
| 
October 6th, 2008, 08:51 AM
| | Member | | Join Date: Mar 2007
Posts: 43
| | Quote: |
Originally Posted by acoder Use cfqueryparam for the data input and set the CFSQLType attribute to use the CF_SQL_DATE type. |
Hi acoder,
Do I do this on the .cfm form page or the action script behind the form?
Thanks
Neil
| 
October 6th, 2008, 11:10 AM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 12,774
| |
It has to be within the query, so that would be the action page.
| 
October 6th, 2008, 02:19 PM
| | Member | | Join Date: Mar 2007
Posts: 43
| | Quote: |
Originally Posted by acoder It has to be within the query, so that would be the action page. |
Acoder,
Thanks for your help, I`m slowly piecing it together...
Neil (i`m a designer dammit, not a coder!)
| 
October 6th, 2008, 02:28 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 12,774
| |
No problem. If you get stuck, post your code and I'll see what I can do.
| 
October 6th, 2008, 03:07 PM
| | Member | | Join Date: Mar 2007
Posts: 43
| | Quote: |
Originally Posted by acoder No problem. If you get stuck, post your code and I'll see what I can do. |
Yup, I`m stuck!
The query takes an inputted workorder number, matches it against the field in the database and returns the unique Workorder value and associated data. It's when the record is updated that the date value is being changed. Here's the associated code:
Find record code: -
-
<cfquery datasource="repairmdb" name="GetClientNo">
-
select ID,
-
WorkshopFK,
-
ClientFK,
-
SiteFK,
-
WORecdate,
-
ResponseLevelFK,
-
ClientWONO,
-
WorkshopWONO,
-
WorkshopJOBNO,
-
AssetNO,
-
AssetClassFK,
-
LocalID,
-
ManufacturerFK,
-
SerialNO,
-
BuildYear,
-
ModelFK,
-
Frame,
-
PowerRating,
-
Volts,
-
Rmin,
-
Amps,
-
Ph,
-
ImpellerDetails,
-
Hz,
-
ExRated,
-
AssetNotes,
-
QuoteP,
-
QuotePDate,
-
Price,
-
QuoteAccepted,
-
QuoteACDate,
-
TargetCDate,
-
UQuoteNotes,
-
ActualCDate,
-
DeliveryDate,
-
FailureReasonFK,
-
FRNotes,
-
RSLoggedDate,
-
RSInspectDate,
-
InspectedByFK,
-
RSQuotedDate,
-
RSApprovedDate,
-
RSWIPDate,
-
AssignedToFK,
-
RSDelDate,
-
RSCompDate
-
from tblWorkshops
-
where 1=1
-
<cfif #form.csearch# is not "">
-
and ClientWONO like '%#form.csearch#%'
-
</cfif>
-
And this is the update query code: -
<cftransaction>
-
-
<cfparam name="form.ExRated" default="0">
-
<cfparam name="form.QuoteP" default="0">
-
<cfparam name="form.QuoteAccepted" default="0">
-
-
-
<cfquery name="updatedatabase" datasource="repairmdb">
-
-
update tblWorkshops
-
set WorkshopFK = '#form.WorkshopFK#',
-
ClientFK = '#form.ClientFK#',
-
SiteFK = '#form.SiteFK#',
-
WORecdate = #form.WORecdate#,
-
ResponseLevelFK = '#form.ResponseLevelFK#',
-
ClientWONO = '#form.ClientWONO#',
-
WorkshopWONO = '#form.WorkshopWONO#',
-
WorkshopJOBNO = '#form.WorkshopJOBNO#',
-
AssetNO = '#form.AssetNO#',
-
AssetClassFK = '#form.AssetClassFK#',
-
LocalID = '#form.LocalID#',
-
ManufacturerFK = '#form.ManufacturerFK#',
-
SerialNO = '#form.SerialNO#',
-
BuildYear = '#form.BuildYear#',
-
ModelFK ='#form.ModelFK#',
-
Frame = '#form.Frame#',
-
PowerRating = '#form.PowerRating#',
-
Volts = '#form.Volts#',
-
Rmin = '#form.Rmin#',
-
Amps = '#form.Amps#',
-
Ph = '#form.Ph#',
-
ImpellerDetails = '#form.ImpellerDetails#',
-
Hz = '#form.Hz#',
-
ExRated = #form.ExRated#,
-
AssetNotes = '#form.AssetNotes#',
-
QuoteP = #form.QuoteP#,
-
QuotePDate = '#form.QuotePDate#',
-
Price = '#form.Price#',
-
QuoteAccepted = #form.QuoteAccepted#,
-
QuoteACDate = '#form.QuoteACDate#',
-
TargetCDate = '#form.TargetCDate#',
-
UQuoteNotes = '#form.UQuoteNotes#',
-
ActualCDate = '#form.ActualCDate#',
-
DeliveryDate = '#form.DeliveryDate#',
-
FailureReasonFK = '#form.FailureReasonFK#',
-
FRNotes = '#form.FRNotes#',
-
RSLoggedDate = '#form.RSLoggedDate#',
-
RSInspectDate = '#form.RSInspectDate#',
-
InspectedByFK = '#form.InspectedByFK#',
-
RSQuotedDate = '#form.RSQuotedDate#',
-
RSApprovedDate = '#form.RSApprovedDate#',
-
RSWIPDate = '#form.RSWIPDate#',
-
AssignedToFK = '#form.AssignedToFK#',
-
RSDelDate = '#form.RSDelDate#',
-
RSCompDate = '#form.RSCompDate#'
-
where ID = #form.ID#
-
-
</cfquery>
-
</cftransaction>
-
-
Not sure if it helps, but our ancient servers are running CF5.
Can't see what i am donig wrong for the date value to be changed in Access to 30/12/1899.
Thanks
Neil
| 
October 6th, 2008, 03:25 PM
| | Member | | Join Date: Mar 2007
Posts: 43
| |
Acoder,
Its okay - I have fixed it. My mistake(Doh!) - I was passing the update value of the date as a number.
The smallest thing, eh?
Thanks for your help.
Neil xxxxxxxxxxxxxx
| 
October 6th, 2008, 04:02 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 12,774
| |
Yes, it usually is the smallest of things causing all the problem.
Glad you managed to solve it.
|  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |