I have a query returning employee, jobcode:
<cfquery name="GetHR" datasource="MyHRDB">
select employee, jobcode
from hrdb
</cfquery>
The query returns:
023598 1332
028977 2908
032409 0180
037325 3350
042242 6220
048140 3121
051482 0430
056176 3110
.....
<cfset expandpath = "D:\HR\">
<cfset HEADER= "employee,jobcode"
<cffile action="Write" file="#expandpath("HRData.csv")#" output="#HEADER#" addnewline="Yes">
<cfoutput query="GetHR">
<cfset CONTENT="#employee#, #jobcode#>
<cffile action="APPEND" file="#expandpath("HRData.csv")#" addnewline="Yes" output="#CONTENT#">
</cfoutput>
However, the .csv file shows the data wihout leading zero(s) like below:
23598 1332
28977 2908
32409 180
37325 3350
42242 6220
48140 3121
51482 430
56176 3110
I tried NumberFormat with:
<cfset CONTENT="#NumberFormat(employee, "000000")#, #NumberFormat(jobcode,"0000")#>
but, the result still shows data without leading zero(s).
How do you put leading zero(s) on the .csv file?
thx much
<cfquery name="GetHR" datasource="MyHRDB">
select employee, jobcode
from hrdb
</cfquery>
The query returns:
023598 1332
028977 2908
032409 0180
037325 3350
042242 6220
048140 3121
051482 0430
056176 3110
.....
<cfset expandpath = "D:\HR\">
<cfset HEADER= "employee,jobcode"
<cffile action="Write" file="#expandpath("HRData.csv")#" output="#HEADER#" addnewline="Yes">
<cfoutput query="GetHR">
<cfset CONTENT="#employee#, #jobcode#>
<cffile action="APPEND" file="#expandpath("HRData.csv")#" addnewline="Yes" output="#CONTENT#">
</cfoutput>
However, the .csv file shows the data wihout leading zero(s) like below:
23598 1332
28977 2908
32409 180
37325 3350
42242 6220
48140 3121
51482 430
56176 3110
I tried NumberFormat with:
<cfset CONTENT="#NumberFormat(employee, "000000")#, #NumberFormat(jobcode,"0000")#>
but, the result still shows data without leading zero(s).
How do you put leading zero(s) on the .csv file?
thx much