For writing data to ouput files we use write command in SQR. And if we have date as one of the output fields, clients prefer '01062014'. This can be achieved by applying formatting to the date field.
Below is the manual way of doing in Excel file. Enter date as show in pic 1 and tab out.
Once we tab out, below is the format of the date that appears in the file.
But this is not we expected. So now lets apply formatting.
So when we prepend =" to date and append ", it converts date to Text format , thus retaining required format.
Fine. Now we need to achieve same through the SQR. Below is the sample code to do the same.
Sample Code:
let $write_header = 'EMPLID,EFFDT,FORMATTED EFFDT'
let $emplid = 'EMP101'
let $effdt = '01022014'
let $text = '="05062014"'
let $delim = ','
write 1 from $write_header
write 1 from $emplid
$delim
$effdt
$delim
$text
SQR Output for a comma separated CSV file
Below is the manual way of doing in Excel file. Enter date as show in pic 1 and tab out.
Once we tab out, below is the format of the date that appears in the file.
But this is not we expected. So now lets apply formatting.
So when we prepend =" to date and append ", it converts date to Text format , thus retaining required format.
Fine. Now we need to achieve same through the SQR. Below is the sample code to do the same.
Sample Code:
let $write_header = 'EMPLID,EFFDT,FORMATTED EFFDT'
let $emplid = 'EMP101'
let $effdt = '01022014'
let $text = '="05062014"'
let $delim = ','
write 1 from $write_header
write 1 from $emplid
$delim
$effdt
$delim
$text
SQR Output for a comma separated CSV file
No comments:
Post a Comment