sql server mseq:
I have to build a text file with a dollar amount that must be right justified, left zero filled and no decimal. The field I am extracting data from is 'amount' and defined as decimal 9(15,2). --
Thanks again Hugo. I'm just getting exposed to SQL and, because of a short deadline, I am being lazy about finding the answers. I shoudl be looking stuff up the old fashioned way. -- Stan Gosselin [quoted text, click to view] "Hugo Kornelis" wrote: > On Fri, 28 Oct 2005 05:35:03 -0700, Stan wrote: > > >I have to build a text file with a dollar amount that must be right > >justified, left zero filled and no decimal. The field I am extracting data > >from is 'amount' and defined as decimal 9(15,2). > > Hi Stan, > > You can use the following expression: > > RIGHT(REPLICATE('0', 11) + LTRIM(CAST(YourColumn * 100 AS INT)), 11) > > Best, Hugo > -- > > (Remove _NO_ and _SPAM_ to get my e-mail address)
[quoted text, click to view] On Fri, 28 Oct 2005 05:35:03 -0700, Stan wrote: >I have to build a text file with a dollar amount that must be right >justified, left zero filled and no decimal. The field I am extracting data >from is 'amount' and defined as decimal 9(15,2).
Hi Stan, You can use the following expression: RIGHT(REPLICATE('0', 11) + LTRIM(CAST(YourColumn * 100 AS INT)), 11) Best, Hugo --
Hugo, If you don't mind, I have a variation on the last question. I have the same type field (decimal 9(15,2)) and the recipient of a conversion .txt file want to see just the meaningful digits, no decimals, no zero fill but does want to see a trailing minus sign for negative numbers. So they want to see 550.45 as 55045 and -45.25 as 4525-. Should I be sending things like this or should I do a re-post? Thanks for understanding. -- Stan Gosselin [quoted text, click to view] "Stan" wrote: > Thanks again Hugo. I'm just getting exposed to SQL and, because of a short > deadline, I am being lazy about finding the answers. I shoudl be looking > stuff up the old fashioned way. > > -- > Stan Gosselin > > > "Hugo Kornelis" wrote: > > > On Fri, 28 Oct 2005 05:35:03 -0700, Stan wrote: > > > > >I have to build a text file with a dollar amount that must be right > > >justified, left zero filled and no decimal. The field I am extracting data > > >from is 'amount' and defined as decimal 9(15,2). > > > > Hi Stan, > > > > You can use the following expression: > > > > RIGHT(REPLICATE('0', 11) + LTRIM(CAST(YourColumn * 100 AS INT)), 11) > > > > Best, Hugo > > -- > > > > (Remove _NO_ and _SPAM_ to get my e-mail address)
Thanks for the direction Hugo! Stan Gosselin [quoted text, click to view] "Hugo Kornelis" wrote: > On Wed, 2 Nov 2005 13:24:02 -0800, Stan wrote: > > >Hugo, > >If you don't mind, I have a variation on the last question. I have the same > >type field (decimal 9(15,2)) and the recipient of a conversion .txt file want > >to see just the meaningful digits, no decimals, no zero fill but does want to > >see a trailing minus sign for negative numbers. So they want to see 550.45 > >as 55045 and -45.25 as 4525-. > >Should I be sending things like this or should I do a re-post? > >Thanks for understanding. > > Hi Stan, > > Sending like this is fine, though a repost might attract more eyes. > Generally, if the subject really changes, post a new message. If it's a > variation on the question, use a reply. > > I see that Steve has already answered the question. I trust that his > reply is what you wanted. > > Best, Hugo > -- > > (Remove _NO_ and _SPAM_ to get my e-mail address)
[quoted text, click to view] On Wed, 2 Nov 2005 13:24:02 -0800, Stan wrote: >Hugo, >If you don't mind, I have a variation on the last question. I have the same >type field (decimal 9(15,2)) and the recipient of a conversion .txt file want >to see just the meaningful digits, no decimals, no zero fill but does want to >see a trailing minus sign for negative numbers. So they want to see 550.45 >as 55045 and -45.25 as 4525-. >Should I be sending things like this or should I do a re-post? >Thanks for understanding.
Hi Stan, Sending like this is fine, though a repost might attract more eyes. Generally, if the subject really changes, post a new message. If it's a variation on the question, use a reply. I see that Steve has already answered the question. I trust that his reply is what you wanted. Best, Hugo --
Don't see what you're looking for? Try a search.
|