How to remove right value from an integer

Posted by Karthik2010_Mca under C# on 1/2/2014 | Points: 10 | Views : 1729 | Status : [Member] | Replies : 10
Hi,

I have an integer value int a = 123456.789000123456
I want to remomve after ".0123456"

Result should be 123456.78900

Thanks

Karthik


Responses

Posted by: Allemahesh on: 1/2/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
I have little confused.
If you have number like this 487548.556585556666
Then you need output as 487548.55658?


Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 1/2/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

int a = 123456.789000123456
this returns a syntax error.

try like this.

decimal b = 123456.789000123456M;
decimal y = Math.Round(b, 5);

OUTPUT of y
123456.78900

Thank you,
Govind

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pallubhosale on: 1/3/2014 [Member] Starter | Points: 25

Up
0
Down
I want sql query which displaysds sum of fee coloumn according to selected year. Database fields r NRIC,file no, title, start date,enddate, fee,
eg .. if I select year 2013 .. it will display total sum of fee for selected year 2013

Pallavi

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 1/3/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

SELECT SUM(fee),startDate,endDate FROM YOURTABLE
GROUP BY GROUPING SETS((startDate),(endDate))
Having startDate like '%2013%' OR endDate like '%2013%'


Thank you,
Govind

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: raghuavulapalli-25110 on: 1/3/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

SELECT startDate,SUM(fee) AS fee FROM YOURTABLE
GROUP BY startDate Having startDate like '%2013%'

Thanks

Raghunath

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 1/3/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Refer this link
http://tutorials.csharp-online.net/CSharp_Format_Specifiers%E2%80%94Numeric_Format_Specifiers

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pallubhosale on: 1/3/2014 [Member] Starter | Points: 25

Up
0
Down
Another condition, sql query which displaysds sum of fee coloumn according to startDate and EndDate. Database fields r NRIC,file no, title, start date,enddate, fee,
eg .. if I select date 06/02/2013 as start date and 31/11/2013 as enddate .. it will display total sum of fee for this duration of
year 2013

Pallavi

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 1/3/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

SELECT startDate,endDate,SUM(fee) AS fee FROM YOURTABLE
GROUP BY startDate,endDate Having startDate = '02-06-2013' AND endDate='11-31-2013'


Thank you,
Govind

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pallubhosale on: 1/3/2014 [Member] Starter | Points: 25

Up
0
Down
Hi Govind , it is giving errors conversion of varchar data type to a datetime datatype resulted in an out of range exception



Pallavi

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 1/3/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,
Try this, date format should be yyyy-mm-dd

SELECT startDate,endDate,SUM(fee) AS fee FROM YOURTABLE
GROUP BY startDate,endDate Having startDate = '2013-02-06' AND endDate='2013-11-31'

Thank you,
Govind

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response