This little error is driving me crazy:

I am trying to populate a datagrid with values from a table based on 
the day selected in the datefield. I can use the datefield to choose 
and pass the value to my webservice but the result returned does not 
reflect the date selected. For example I can select 2/9/2007 and the 
service sends 2/8/2007 if it sends any data at all.

Is my error in flex or in my webservice. I know this is not a 
coldfusion forum but I use a cffunction as my service. I feel it may 
be flex related since occasionally I can get the same error in 
VB.net.  


When the component is created I set the default date of the datefield 
using the following code in the DateField Creation Complete event:


creationComplete="dtcLogDate.selectedDate = new Date();" 


The initialized the data loads properly based on the above setting 
but when I start changing the date is where the problem exists.


I pass the variable as the input parameter in the service using:

<mx:request>
        <dateVar>{dtcLogDate.selectedDate}</dateVar>
</mx:request>


My webservice is below as you can see I receive the dateVar as a 
cfarugment I then break it down into dayparts in order to filter my 
data since the data, which being filtered is stored in "mm/dd/yyyy 
hh:mm:ss AM" format in the db.

<cffunction 
                name="getLogHistory" 
                displayname="getLogHistory" 
                hint="I get the log history for display" 
                access="remote" 
                output="false" 
                returntype="query">
                
<cfargument name="dateVar" required="false" />
                                
<cfset scheduleMonth = #DateFormat(arguments.dateVar, "mm")#>
<cfset scheduleDay = #DateFormat(arguments.dateVar, "dd")#>
<cfset scheduleYear = #DateFormat(arguments.dateVar, "yyyy")#>
                
                
<cfquery name="gryLogHistory" datasource="test">
SELECT
  E.first_name,
  E.last_name,
  E.address,
  E.city,
  E.state,
  E.zip,
  E.email,
  E.phone as empPhone,
  STUFF(CONVERT(char(19), L.logrecord , 100),1,12,'') AS 
LogInTime,
  L.eid,
  S.store_code,
  S.address as StoreAddress,
  S.city as StoreCity,
  S.state as StoreState,
  S.phone as StorePhone
FROM dbo.loghistory AS L
INNER JOIN dbo.employees AS E
ON L.eid = E.eid
INNER JOIN dbo.stores AS S
ON S.sid = E.sid
WHERE DATEPART(yyyy, L.logrecord) = #scheduleYear# AND 
        DATEPART(mm, L.logrecord) = #scheduleMonth# AND
        DATEPART(dd, L.logrecord) = #scheduleDay# 
        order by logrecord desc
</cfquery>
<cfreturn gryLogHistory />
</cffunction>

Thanks in advance!
Shawn



Reply via email to