Sum up time?
How do I sum up time, eg, 7:56 + 5:28 + 1:40 (minutes:seconds) in Numbers?
Louise,
You should be aware of the types that Numbers recognizes.
there are strings just letters and numbers and symbols:
e.g.:
Wayne, or Hi there, or "123 Happy Street"
There are numeric values:
e.g.:
1, or , 1000, or 56.654, or 3.14159265, or -90
There are Date/Time values:
1/1/2012 2:09 AM, 5/6/1999, or 5:56:22 PM
In the last two cases even if you do not enter the "other" part numbers will add it. That is if you type "5/6/1999" only, then Numbers will add the time you entered the date. A date/time value will always include both even if you did not enter the other part.
There are Durations, which are the difference between two times. Technically, you cannot add times (when they are a date/time value). Ask yourself how do you add "1/2/2014 5:45:09 AM" to "4/6/1980 12:31:00 AM"?
you can however get the amount of time that has passed from one time to another... this is called a duration. Durations can be added and subtracted. Elapse time is really a duration expressed in weeks, days, hours, minutes, seconds, milliseconds.
I hope this helps you understand SGIIIs post.
you enter durations as "3h 45m 21s" or "6w 3h 2m 1s" (you would leave out the double quotes)
Here is an exapmle where I entered some durations and added them up:
A6=SUM(A2:A5)
this is shorthand for select cell A6, then type (or copy and paste from here) the formula:
=SUM(A2:A5)
Similar Messages
-
BPC 10.1 - no sum on time dimension
Hi,
we've a BPC 10.1 sandbox and we're facing several problems
#3 no sum on time Dimension
If you check the attached file you will see that there is no summing up on the time Dimension. I've checked that on BPC 7.5 and 10.0 and it should work on 10.1 as well but it doesn't ... e.g. Account Dimension works fine
Any idea or hint?
ThxYes
We used the "BPC_HANA_MIGRATE_FROM_10" as well -
id time
1 1.20
2 2.30
3 4.20
4 5.30
5 1.00
result expected = 14:40 or (if AM/PM so result=???)
how can i calculate the sum of time ???
please give me some fast tricks of handling date/time formate in oracle....942425 wrote:
id time
1 1.20
2 2.30
3 4.20
4 5.30
5 1.00
result expected = 14:40 or (if AM/PM so result is ???)
how can i calculate the sum of time ???
please give me some fast tricks of handling date/time formate in oracle....Hi,
First you post in wrong forum. Please post at PL/SQL
Before posting there close it and mark as answered.
if your time is number data type then you can try this
SELECT SUM(NVL(ROUND(TRUNC(DAC_OT_HOUR)+((TO_NUMBER (SUBSTR (DAC_OT_HOUR, INSTR (DAC_OT_HOUR,'.',1,1)+1)))/60)),0))
FROM DA_CHECKHope this helps
Hamid
Mark correct/helpful to help others to get right answer(s).* -
Sum of Time "Hours & Minutes" in stardard list
Hi,
in list where it's possible to have a sum of time (as in my case transaction IW47, list of confirmation time), I can make as usual the sum of time but the system let separated hours from minutes having as result e.g.:
32 hrs
412 min
is there any standard possibility to sum them in only 1 unit of measure?
Thanks.sorry, but is not a SAPGUI question. you should ask this in the proper functional area or in the ABAP forum.
-
Finding sum for time field in alv
hi gurus.,
i need to find total hours.. i am using field of data type 'TIMS' ... i converted the value to decimal in ALV and founfd total hours .. i need the total hours in Time format .. how can i achieve this in alv .. its very urgent ...
thanks®ards.,
S.SivakumarHi Shivakumar,
I suggest you not to convert TIMS to Decimal
because it won't give you correct result..
Eg...
Time1 = '11:56:32'
Time2 = '11:50:10'
now add these two times...
u will get the sum of these as 23:06:42
but in real life... you want the result as 23:46:42
So the better way for getting accurate result is to convert this
HH:MM:SS to Seconds
and then sum these seconds
then again convert it to HH:MM:SS
1 hr = 3600 sec
1 min = 60 sec
Hope it will solve your problem...
Reward points if useful...
Thanks & Regards
ilesh 24x7 -
hello,
In rdlc report i need to sum the date time datatype .
please help .
thanks.Hi Krishnakumar_Dev,
If we want to extract hour in a date time field, we can use hour function as below in Reporting Services.
=sum(hour(Fields!date.Value))
Besides, if this issue is still existed, Could you please post the screenshot about your dataset with sample data and desired result?
For more information about Date and Time Functions, please refer to the following link:
http://technet.microsoft.com/en-us/library/aa337153(v=sql.100).aspx
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Hi,
I'm trying to do something which I would guess is quite a common query, but after scratching my head and perusing the web I am still no closer to a solution.
I am running:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
I'm looking to sum up a set of values, taking into account both a parent grouping and start and end dates.
For the parent grouping I am using:
+SUM([value]) over (Partition by [Parent] order by [Parent],[Child])+
And I was hoping to be able to extend this SUM to also handle the start and end dates, so the final output would contain a sum of the values for each different time period.
As an example, using the data below I'm trying to sum up the price of the components of a car over time:
row, product, component, rate, start date, end date
1, car, chassis, 180, 01/01/2000, 31/12/2009
2, car, chassis, 200, 01/01/2010, 01/01/2050
3, car, engine, 100, 01/01/2000, 01/01/2050
Notice there is a change of price for Component 'chassis', so the output I'm looking for is:
row, product, component, rate, start date, end date, sum
1, car, chassis, 180, 01/01/2000, 31/12/2009, 280
2, car, engine, 100, 01/01/2000, 31/12/2009, 280
3, car, chassis, 200, 01/01/2010, 01/01/2050, 300
4, car, engine, 100, 01/01/2010, 01/01/2050, 300
But in reality all I need is:
row, product, start date, end date, sum
1, car, 01/01/2000, 31/12/2009, 280
2, car, 01/01/2010, 01/01/2050, 300
Preferably the query would be in a view rather than a stored procedure, and it needs to be able to handle many 'products', 'components' and start/end dates.
All help most appreciated, and if any more info is required, please let me know.
Thanks,
JulianHi Frank,
Thanks for picking up this query, I'll try to explain my points in more detail:
+SUM([value]) over (Partition by [Parent] order by [Parent],[Child])+I don't see columns called value, parent or child in the sample data below.
Is value the same as rate? What are parent and child? In the example:
Product is the parent
Component is the child
Rate is the value
Whenever you have a problem, post CREATE TABLE and INSERT statments for your sample data.CREATE TABLE "REPOSITORY"."PRODUCT_RATES"
( "PRODUCT" VARCHAR2(255 BYTE),
"COMPONENT" VARCHAR2(255 BYTE),
"RATE" NUMBER(9,2),
"START_DATE" DATE,
"END_DATE" DATE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "SHOP_AREA" ;
insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('car', 'chassis', 180, to_date('01-01-2000','dd-mm-yyyy'), to_date('31-12-2009','dd-mm-yyyy'))
insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('car', 'chassis', 200, to_date('01-01-2010','dd-mm-yyyy'), to_date('01-01-2050','dd-mm-yyyy'))
insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('car', 'engine', 100, to_date('01-01-2000','dd-mm-yyyy'), to_date('01-01-2050','dd-mm-yyyy'))
Although the above short scenario highlights my issue, to expand on the example data set:
insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('family', 'wife', 500, to_date('01-01-2000','dd-mm-yyyy'), to_date('31-12-2001','dd-mm-yyyy'))
insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('family', 'wife', 999, to_date('01-01-2002','dd-mm-yyyy'), to_date('01-01-2050','dd-mm-yyyy'))
insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('family', 'baby', 250, to_date('01-01-2000','dd-mm-yyyy'), to_date('31-12-2004','dd-mm-yyyy'))
insert into REPOSITORY.PRODUCT_RATES (PRODUCT, COMPONENT, RATE, START_DATE, END_DATE) values ('family', 'baby', 500, to_date('01-01-2005','dd-mm-yyyy'), to_date('01-01-2050','dd-mm-yyyy'))
Notice there is a change of price for Component 'chassis', so the output I'm looking for is:
row, product, component, rate, start date, end date, sum
1, car, chassis, 180, 01/01/2000, 31/12/2009, 280
2, car, engine, 100, 01/01/2000, 31/12/2009, 280
3, car, chassis, 200, 01/01/2010, 01/01/2050, 300
4, car, engine, 100, 01/01/2010, 01/01/2050, 300Explain how you get 4 rows of output when the table contains only 3 rows. Are you saying that, because some row has end_date=31/12/2009, then any other row that includes that date has to be split into two, with one row ending on 31/12/2009 and the other one beginning on the next day?
Explain, step by step, how you get the values in the desired output, especially the last column.
But in reality all I need is:Sorry, I can;'t understand what you want.
Are you saying that the output above sould be acceptable, but the output below would be even better?
row, product, start date, end date, sum
1, car, 01/01/2000, 31/12/2009, 280
2, car, 01/01/2010, 01/01/2050, 300
Preferably the query would be in a view rather than a stored procedure, and it needs to be able to handle many 'products', 'components' and start/end dates.Include a couple of differtent products in your sample data and results.
I'm not sure what you want, but there's nothing in what you've said so far that makes me think a stored procedure would be needed.The only output I actually require is:
row, product, component, rate, start date, end date, sum
1, car, 01/01/2000, 31/12/2009, 280
2, car, 01/01/2010, 01/01/2050, 300and with the extended data set:
3, family, 750, 01/01/2000, 31/12/2001
4, family, 1249, 01/01/2002, 31/12/2004
5, family, 1499, 01/01/2005, 31/12/2050however, I was thinking that the data set would need to be somehow expanded to get to the above end result, hence why I included the 'middle step' of:
row, product, component, rate, start date, end date, sum
1, car, chassis, 180, 01/01/2000, 31/12/2009, 280
2, car, engine, 100, 01/01/2000, 31/12/2009, 280
3, car, chassis, 200, 01/01/2010, 01/01/2050, 300
4, car, engine, 100, 01/01/2010, 01/01/2050, 300however, this may be irrelevent.
By the way, there's no point in using the same expression in both the PARTITON BY and ORDER BY clauses of the same analytic function call. For example, if you "PARTITION BY parent", then, when "ORDER BY parent, child" is evaluated, rows will only be compared to other rows with the same parent, so they'll all tie for first place in "ORDER BY parent". OK, thanks.
So far I have got to:
select
sum(rate) over (partition by product) as sum,
a.*
from product_rates a
which results in:
SUM PRODUCT COMPONENT RATE START_DATE END_DATE
480 car engine 100 2000-01-01 00:00:00.0 2050-01-01 00:00:00.0
480 car chassis 200 2010-01-01 00:00:00.0 2050-01-01 00:00:00.0
480 car chassis 180 2000-01-01 00:00:00.0 2009-12-31 00:00:00.0
2249 family baby 250 2000-01-01 00:00:00.0 2004-12-31 00:00:00.0
2249 family wife 999 2002-01-01 00:00:00.0 2050-01-01 00:00:00.0
2249 family baby 500 2005-01-01 00:00:00.0 2050-01-01 00:00:00.0
2249 family wife 500 2000-01-01 00:00:00.0 2001-12-31 00:00:00.0
but this shows that all price variations for a component over time are being summed (e.g. car enging 100 + car chassis 200 + car chassis 180 = 480)
Hope that goes someway expaling my query better.
Also, quick query to improve my postings - how do i indent without making text ittallic, and how do you make code a different font?
Thanks again.
Julian -
What formula for finding sum of Time from cells in a row?
Is there a template on Numbers or a simple Sum formula that i can use to add hours and minutes worked so that a cell will show total number of hours and minutes worked in a day? Thanks.
In its bare form, the required formula would be :
=(timeOut1-timeIn1)+(timeOut2-timeIn2)+(timeOut…-timeIn…)
this said, you must understand that Numbers has no time items.
It has date_time ones and, if it's Numbers '09, it has duration ones.
A cell whose format is defined to display only a time value contains always a date component.
Near the safari window in which I am writing is a Numbers document.
If I type 13:58:20 in cell B2, the app starts displaying 13:58 because the contents parser which is in Automatic mode recognized that my entry was resembling to a time one. So it « decided » to display only the hours and minutes of the time component.
If I enter the Cells Inspector and define the format to date time displaying the date and the time (with seconds), I get: 2012-04-12 13:58:20
If the process whose start was just typed is supposed to end at 18:26, I may repeat the already described process to C2 but as quite everybody knows in this Discussions forum, I'm lazy.
So, I select every cells supposed to receive a time value and define, temporarily, their format to date_time displaying date, time with seconds. This way I will not have to repeat that for every entry.
In C2, I type 18:26.
The app displays : 2012-04-12 18:26:00
Leaving space for two other tasks, in H2, I type =C2-B2
As I am running Numbers '09, I get 4h 27m 40s which is a duration value.
Now, we will assume that the start time remains unchanged but that the task will end tomorrow at 5:55
If I type this value immediately in C2, the cell will contain 2012-04-12 05:55:00 and H2 will contain -8h 3m 20s which is certainly not what you want to get.
If I wait tomorrow before typing this end time in C2, the cell will contain 2012-04-13 05:55:00 and H2 will display the wanted value : 15h 56m 40s.
CAUTION : the application made no error, it just did exactly what I wanted it to achieve.
Third case, I decide to type the start and the end time when the task isfinished, say on 2012-04-14,
B2 will contain : 2012-04-14 18:26:00
C2 will contain : 2012-04-14 05:55:00
and one more time we will get the infamous -8h 3m 20s which is certainly not what you want to get.
So, it's clear that a more sophisticated formula is required.
Here I will describe the one which I use. I guess that other helpers will describe other ones. It's the rule of the game.
I use the function TIMEVALUE.
=(TIMEVALUE(C2)-TIMEVALUE(B2)+IF(TIMEVALUE(C2)>TIMEVALUE(B2),0,1))*24
which will return the durations expressed in decimal hours.
This formula is OK as long as the task duration isn’t longer than 24 hours.
If a task duration may be greater than 24 hours, the best scheme would be to enter full date_time values.
For several tasks, the formula would be :
=(TIMEVALUE(C2)-TIMEVALUE(B2)+IF(TIMEVALUE(C2)>TIMEVALUE(B2),0,1)+TIMEVALUE(E2)- TIMEVALUE(D2)+IF(TIMEVALUE(E2)>TIMEVALUE(D2),0,1)+TIMEVALUE(G2)-TIMEVALUE(F2)+IF (TIMEVALUE(G2)>TIMEVALUE(F2),0,1))*24
Yvan KOENIG (VALLAURIS, France) jeudi 12 avril 2012
iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.3
My Box account is : http://www.box.com/s/00qnssoyeq2xvc22ra4k -
Hi. I need to know how can I calculate sum by date and time. I've got collection with date column, time column, value column and sums column with label in it . I tried in sumsColumn-label1 Text= Sum(Filter(Collection, dateColumn<=ThisItem!dateColumn),
TimeValue(timeColumn)<=TimeValue(ThisItem!timeColumn), valueColumn*1). This doesn't work. It works great with datum but not with time so if I have two values at same date it sums both values. I want that sums column calculate sum continuously by each value
so that's why I added time column. Please help. ThanksHi Ptr,
I believe you want to calculate a cumulative sum per Day. If I use your example, you start with 3 rows:
10 | 1/1/14
15 | 2/1/14
15 | 2/1/14
And you want to display the total sum in the gallery to see something like this:
(1st item in Gallery) (2nd item in Gallery) (3rd item in Gallery)
1/1/14 2/1/14
2/1/14
10 25 40
One possible way to accomplish this is to add another a column to your original data called Index and make sure the first index is the oldest entry and the largest index is the most recent. Something like:
10 | 1/1/14 | 1
15 | 2/1/14 | 2
15 | 2/1/14 | 3
Once you have this, you can then set the Text property expression of your label inside the Gallery to:
Sum(Filter(Collection1, Index<=ThisItem!Index), Amount)
Alternatively, instead of creating an Index column, you create a new column that combines Date and Time together into a single column
DateTime. If you use Excel make sure to format all cells of this column to a Date type (e.g. 3/14/12 1:30PM). In Siena, the expression would then become:
Sum(Filter(Collection1, DateTime<=ThisItem!DateTime), Amount)
Cheers,
Olivier -
Hi,
is there a way to sum time data as following?
start_time: 10,15 AM
stop_time: 2,35 PM
I expect to do something like:
=(stop_time - start_time)
but this doesn't work.
Thanks anticipately.Currently we support arithmetic formulas on 12 hour intervals only, i.e., you can perform the following action (Stop_time - Start_time) for Start_time: 1:00AM and Stop_time: 9:00AM. Tables will display 8:00AM as the result. Please make sure you select "date" as the data type for all the columns associated with this operation.
Thanks,
Varun -
Error when adding the sums of time duration when 1 cell value is 0
I am creating a very basic spreadsheet on my iPad to be used as a time clock by my 3 employees. Columns A & B are times in and out respectively and column C is the duration (B-A.) Rows 1-6 are Monday-Saturday and row 7 (specifically cell C7) is the sum of the durations of each day. So far, so good. Here's the problem...I would like to keep the same formula (C=B-A) in each cell from C1 to C6 regardless of whether or not that employee actually worked that day. When nothing is entered into columns A or B, the resulting value for column C is 0. When the value of any cell in column C is 0, the formula in cell C7 (=sumC1:C6) results in an error. Any ideas???
Also, is it possible to cut or delete the text of a cell and leave the cell formatting (i.e. fill colors, text color, boarder, etc)?
Thanks again,
Matt"When the value of any cell in column C is 0, the formula in cell C7 (=sumC1:C6) results in an error. Any ideas???"
Hi Matt,
The error is that SUM cannot deal with a collection of values that contains both durations (eg. 1h 12m) and numbers ( eg. 0 ).
Don't let the value in any cell in the range be 0.
Your formula in column C is now: =B-A
If both B and A are empty, the result will be zero.
Use this revised formula: =IF(OR(LEN(A)<1,LEN(B)<1),"",B-A)
If either of the cells required to complete the subtraction has no data, the formula rturns a null string—a text value, which will be ignored by SUM. When both A and B contin Date and Time values, the formula returns a duration, and SUM will work.
Regards,
Barry -
I've got a query that looks like this
SELECT C.NAME CUSNAME, E.FIRST_NAME||' '||E.LAST_NAME SALESPERSON, SUM(S.TOTAL) SALES, R.DESCRIPTION PRODUCTDES,
(R.VALUE/SUM(S.TOTAL))*100 TOTAL
FROM ITEM I, SALES_ORDER S, CUSTOMER C, employee e,
(SELECT * FROM (select S.CUSTOMER_ID, P.DESCRIPTION, SUM(I.TOTAL) VALUE,
ROW_NUMBER() over (partition by S.CUSTOMER_ID ORDER BY SUM(I.TOTAL) DESC) AS RN
FROM ITEM I, SALES_ORDER S, PRODUCT P
WHERE P.PRODUCT_ID = I.PRODUCT_ID
AND S.ORDER_ID = I.ORDER_ID
GROUP BY
S.CUSTOMER_ID,P.DESCRIPTION) WHERE RN = 1) R
WHERE S.ORDER_ID = I.ORDER_ID AND C.CUSTOMER_ID = S.CUSTOMER_ID AND E.EMPLOYEE_ID = C.SALESPERSON_ID
AND R.CUSTOMER_ID = S.CUSTOMER_ID
group by c.name, e.first_name, e.last_name, r.description, r.value;
Every thing is fine in it apart from the fact that the Sum(s.total) in the first line returns a value that is 4 times the value it should be. I don't know why this is, it must be entering the same table 4 times. Can anyone solve this problem.You could put your text between [ pre ] and [ / pre ] in order to preserve the format.
Something like below.
SELECT C.NAME CUSNAME,
E.FIRST_NAME||' '||E.LAST_NAME SALESPERSON,
SUM(S.TOTAL) SALES,
R.DESCRIPTION PRODUCTDES,
(R.VALUE/SUM(S.TOTAL))*100 TOTAL
FROM ITEM I,
SALES_ORDER S,
CUSTOMER C,
employee e,
(SELECT * FROM
(select S.CUSTOMER_ID,
P.DESCRIPTION,
SUM(I.TOTAL) VALUE,
ROW_NUMBER() over (partition by S.CUSTOMER_ID ORDER BY SUM(I.TOTAL) DESC) AS RN
FROM ITEM I,
SALES_ORDER S,
PRODUCT P
WHERE P.PRODUCT_ID = I.PRODUCT_ID
AND S.ORDER_ID = I.ORDER_ID
GROUP BY S.CUSTOMER_ID,
P.DESCRIPTION
WHERE RN = 1
) R
WHERE S.ORDER_ID = I.ORDER_ID
AND C.CUSTOMER_ID = S.CUSTOMER_ID
AND E.EMPLOYEE_ID = C.SALESPERSON_ID
AND R.CUSTOMER_ID = S.CUSTOMER_ID
group by c.name,
e.first_name,
e.last_name,
r.description,
r.value; -
Dear All,
I want to sum up of the Time field in Crystal Report. For example I have times as 8.30, 8.30, 9.30, 10.00, 8.30. So the sum should be shown as 44.20. How to achieve this in crystal report.
Regards,
KamleshDo you require to show sum as 44.20 or 45.00?
in case of showing 45 hours
create formulas
1. hrs : DatePart('H', )
2. minutes : DatePart('M', )
3. Sum : totext( Sum ({@hrs})+ INT(Sum ({@minute})/60),0,"")&":"&totext(remainder( Sum ({@minute}),60),"00")
Jyothi
Edited by: Jyothi Yepuri on Sep 10, 2009 2:13 AM -
Sum of Time (Urgent)
Hi all,
I have 1 field in table called timetaken,datatype Varchar2 and i m storing time in '00:00:00' format ..
I have to add or sum all da values of this col
like timetake
00:00:02
00:00:02
so total shud come 00:00:04
Like tht i have to sum tht col..
Can u please suggest me .. who can i do thisI have a very CRUDE pl/sql solution for this.
declare
varss1 number(10);
varss2 number(10);
varss3 number(10);
varmm1 number(10);
varmm2 number(10);
varmm3 number(10);
varhh1 number(10);
varhh2 number(10);
varhh3 number(10);
cursor c1 is
select to_number(substr(col1,7,2)) sec,
to_number(substr(col1,4,2)) mn,
to_number(substr(col1,1,2)) hr
from timings;
begin
varss1 := 0;
varmm1 := 0;
varhh1 := 0;
for tab in c1
loop
varss1 := varss1 + tab.sec;
varmm1 := varmm1 + tab.mn;
varhh1 := varhh1 + tab.hr;
end loop;
dbms_output.put_line('the total is -> '||varhh1||':'||varmm1||':'||varss1);
varss2 := trunc(varss1/60);
varss3 := mod(varss1,60);
varmm2 := trunc(varmm1/60);
varmm3 := mod(varmm1,60);
varmm3 := mod(varmm1,60)+varss2;
varhh1 := varhh1 + varmm2;
varhh2 := trunc(varhh1/24);
varhh3 := mod(varhh1,24);
dbms_output.put_line('the total in number of Days:Hrs:Mins:Secs formate is --->
'||varhh2||':'||varhh3||':'||varmm3||':'||varss3);
end;
Regards. -
Dear Experts,
I've a field which displays the minutes input to the HH.MM format.
Please help me in managing the SUM of this column in the same format. Presenlty I am getting in the decimal system.
(The above field type is in DEC 10 2 )
Regards
Jogeswara Rao
Moderator message: duplicate post.
Edited by: Thomas Zloch on Jun 16, 2011 9:39 AMhi
thanks to all ,thanks a lot
at last the issue is solved ,i got a user defined function for padding .It seems there is no built in function for padding in SQL 2005.
if i am wrong please point out , so i think it is a helpful function please check out this ...
IF EXISTS (
SELECT *
FROM dbo.sysobjects
WHERE id = object_id(N'[dbo].[fnPadLeft]')
AND xtype IN (N'FN', N'IF', N'TF')
DROP FUNCTION [dbo].[fnPadLeft]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE FUNCTION fnPadLeft
@PadChar char(1),
@PadToLen int,
@BaseString varchar(100)
RETURNS varchar(1000)
AS
Author: Daniel Read
Description:
Pads @BaseString to an exact length (@PadToLen) using the
specified character (@PadChar). Base string will not be
trimmed. Implicit type conversion should allow caller to
pass a numeric T-SQL value for @BaseString.
Unfortunately T-SQL string variables must be declared with an
explicit width, so I chose 100 for the base and 1000 for the
return. Feel free to adjust data types to suit your needs.
Keep in mind that if you don't assign an explicit width to
varchar it is the same as declaring varchar(1).
Revision History:
Date Name Description
BEGIN
DECLARE @Padded varchar(1000)
DECLARE @BaseLen int
SET @BaseLen = LEN(@BaseString)
IF @BaseLen >= @PadToLen
BEGIN
SET @Padded = @BaseString
END
ELSE
BEGIN
SET @Padded = REPLICATE(@PadChar, @PadToLen - @BaseLen) + @BaseString
END
RETURN @Padded
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Maybe you are looking for
-
"songs on the iPod cannot be updated because all of the playlists selected for updating no longer exist" this has never happened to me before in all my years of ipod usage. help please?
-
Thunderbolt to Firewire doesn't see External HardDrive
Greetings... I was setting up my Mom's new MacBookAir, and I had to aquire a Thunderbolt Adapter (to Firewire 800). She used an External drive for her Time Machine backup previously. It is a Maxtor OneTouch drive, but it uses the older Firewire por
-
Problem with local class, static private attribute and public method
Hello SDN, Consider the following situation: 1) I have defined a LOCAL class airplane. 2) This class has a private static attribute "type table of ref to" airplane (array of airplanes) 3) A public method should return the private static table attribu
-
A few days ago my MacBook Pro froze and I had to force it to shut down. The next time (and all subsequent times) I've turned on my computer to login, as the username is shows (My name's) MacBook Pro (2). The (2) is new... what does it mean? Is there
-
Calling javascript functions from xsl on mac safari
Hi, I am having a problem calling external javascript functions from xsl on mac safari, i am trying to generate a dropdown dynamically from an xsl document using XSLTProcessor through javascript, following is the code snippet of the xsl document <sel