| Author |
Topic |
|
Asdzxc1986
Starting Member
14 Posts |
Posted - 2009-11-18 : 03:28:43
|
Have a simple formula:Time_Unload=Quantity*Time_for_one_thing;Quantity floatTime_for_one_thing datetimeI dont know how to convert float to datetime.Example:I have 4,5 boxes, and 15 minutes time for unloading per box.as a result I have to get 4,5*15min = 67,5 min or 1 hour 7 min 30 sec. I will be thankful |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-11-18 : 03:52:00
|
| Post table structure, sample data and expected resultMadhivananFailing to plan is Planning to fail |
 |
|
|
Asdzxc1986
Starting Member
14 Posts |
Posted - 2009-11-18 : 04:30:05
|
| table OrdersId int primary key...Quantity floatTime_for_one_thing datetimeTime_Unload datetime...I need to fill time_unload column for every order.I have already algorythm how to do it. I need only convert expression 4,5*15min to 1 hour 7 min 30 sec.Do you need any other information? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-11-18 : 04:37:52
|
looks like your Time_for_one_thing is in minute. Then you should just use integer data type and not datetime KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Asdzxc1986
Starting Member
14 Posts |
Posted - 2009-11-18 : 05:02:03
|
You right. I can use int for Time_for_one_thing, but Time_unload I can't change. It should be datetime. So expression like 4,5*15 I have to convert to 1 hour 7 min 30 secquote: Originally posted by khtan looks like your Time_for_one_thing is in minute. Then you should just use integer data type and not datetime KH[spoiler]Time is always against us[/spoiler]
|
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-11-18 : 05:17:23
|
assuming the Time_for_one_thing is integerselect Time_unload = dateadd(minute, Quantity * Time_for_one_thing, 0)from yourtable another question, any particular reason quantity is float ? Are you expecting decimal places in quantity ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-18 : 05:22:10
|
So timepart is needed only in a datetime field.I have set the datepart to 19000101 because it is not interesting...declare @Quantity floatdeclare @Time_Unload datetimedeclare @Time_for_one_thing intset @Time_for_one_thing = 15 -- minutesset @Quantity = 4.5select dateadd(second,(@Quantity * @Time_for_one_thing) * 60, '19000101') gives: 1900-01-01 01:07:30.000 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Asdzxc1986
Starting Member
14 Posts |
Posted - 2009-11-18 : 05:38:16
|
| webfred, khtan thanks. It works!2khtan: unfortunately quantity should be float. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-18 : 05:58:22
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|