I have a problem with the DateFormat() Function that is driving me nuts!
I am downloading a csv and then parsing through it, then inserting into a SQL 2005 DB. Here is the problem. ...
A number of fields that are passed are strings representing dates.
E.G. 20080324
( which I read as 2008/03/24)
Sometimes they are there sometimes they are not.
When I perform a DateFormat on them to set them in my VAR, this is what I am getting back for the same data:
01/20/56878
Now I may be missing something but those are not even the same numbers.
Here is a sample of my code:
- <CFIF FileExists("#csvTSSavePath#\#cvsTSFilename#.CSV")>
-
<cffile action="read" file="#csvTSSavePath#\#cvsTSFilename#.CSV" variable="csvFile">
-
<cfset csvFile = Replace(csvFile, chr(34), "", "all")>
-
<!--- Convert the lines to an array using the carriage return/line feed characters as delimiters --->
-
<cfset FileLines = listtoarray(ListFix(csvFile),"#chr(13)##chr(10)#")>
-
<!--- Loop through the array of lines Use the number from="2" to eliminate the first row of data--->
-
<cfloop from="2" to="#arrayLen(FileLines)#" index="i">
-
<cfset AUCTDATE = "#listgetat(FileLines[i],11)#">
-
<cfset DEFLTDAT = "#listgetat(FileLines[i],10)#">
-
<cfset PUBDATE = "#listgetat(FileLines[i],126)#">
-
<cfset RECDATE = "#listgetat(FileLines[i],125)#">
-
<cfset LOAN_DATE = "#listgetat(FileLines[i],3)#">
-
<cfset DATE_SOLD = "#listgetat(FileLines[i],72)#">
-
<CFIF AUCTDATE EQ "NULL"><cfset AUCTDATE = "NULL"><CFELSE><cfset AUCTDATE = "#DateFormat(listgetat(FileLines[i],11), "mm/dd/yyyy")#"></CFIF>
-
<CFIF DEFLTDAT EQ "NULL"><cfset DEFLTDAT = "NULL"><CFELSE><cfset DEFLTDAT = "#DateFormat(listgetat(FileLines[i],10), "mm/dd/yyyy")#"></CFIF>
-
<!--- <CFIF PUBDATE EQ "NULL"><cfset PUBDATE = "NULL"><CFELSE><cfset PUBDATE = "#DateFormat(listgetat(FileLines[i],126), "mm/dd/yyyy")#"></CFIF> --->
-
<CFIF RECDATE EQ "NULL"><cfset RECDATE = "NULL"><CFELSE><cfset RECDATE = "#DateFormat(listgetat(FileLines[i],125), "mm/dd/yyyy")#"></CFIF>
-
<CFIF LOAN_DATE EQ "NULL"><cfset LOAN_DATE = "NULL"><CFELSE><cfset LOAN_DATE = "#DateFormat(listgetat(FileLines[i],3), "mm/dd/yyyy")#"></CFIF>
-
<CFIF DATE_SOLD EQ "NULL"><cfset DATE_SOLD = "NULL"><CFELSE><cfset DATE_SOLD = "#DateFormat(listgetat(FileLines[i],72), "mm/dd/yyyy")#"></CFIF>
-
-
-
<cfoutput>
-
#AUCTDATE#<BR />
-
#DEFLTDAT#<BR />
-
#PUBDATE#<BR />
-
#AUCTDATE#<BR />
-
#RECDATE#<BR />
-
#LOAN_DATE#<BR />
-
#DATE_SOLD#<BR />
-
</cfoutput>
Any help would be much apreciated. Thanks in advance.