Hi,
I am trying to add leading zeros to a field but the zeros are not displying in the results.
The code below will display the added zeros because I have a space at the beginning of my leading zeros:
Results: ' 0000000999999'
Note: DATE_FIELD is a float in tbl_1
But when I add the RIGHT function to cut the field down to 7 characters I get the following:
Displayed Results: '999999'
I want to see this displayed as '0999999'
I've tried casting the whole RIGHT function to a char(7) but that doesn't work.
Can someone please help tell me how I can get the zeros to display?
I am trying to add leading zeros to a field but the zeros are not displying in the results.
The code below will display the added zeros because I have a space at the beginning of my leading zeros:
Code:
SELECT ' 0000000'+ STR(DATE_FIELD,7,0) as DATEFMT FROM tbl_1
Note: DATE_FIELD is a float in tbl_1
But when I add the RIGHT function to cut the field down to 7 characters I get the following:
Code:
SELECT RIGHT(' 0000000'+ STR(DATE_FIELD,7,0),7) as DATEFMT
FROM tbl_1
I want to see this displayed as '0999999'
I've tried casting the whole RIGHT function to a char(7) but that doesn't work.
Can someone please help tell me how I can get the zeros to display?
Comment