GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  DotNet
Go To First  |  Previous Question  |  Next Question 
 DotNet  |  Question 121 of 165    Print  
1).please write an example of getting the smallest value than can sub divde"128"

2).please write an example of convertinfg string value "31/12/2000" to date time and at the same time change its format "mm/dd/yy"

3). please write an example of reurnning a date that is the last day of the month.8 months from todays date

4).please write an example of formatting a variable of fromatting a variable in doubble data type with value "1800000.7" to "$1,8000.000.70"

  
Total Answers and Comments: 4 Last Update: January 02, 2007     Asked by: naveenreddi 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 11, 2006 21:09:13   #1  
Topgun        

RE: 1).please write an example of getting the smallest...

int number 128;

int i 1;

While(i < (number/2))

{

if ( number i 0)

return number;

i++;

}


 
Is this answer useful? Yes | No
September 11, 2006 21:11:17   #2  
prasad        

RE: 1).please write an example of getting the smallest...

Q2)

System.DateTime dt System.DateTime.Now.AddMonths(8);

int month dt.Month;

int i 1;

while( month dt.AddDays(i).Month)

{

i+ 1;

}

System.DateTime lastDayOfMonth dt.AddDays(i-1);

System.DateTime 8thLastDayOfMonth dt.AddDays(i-1);


 
Is this answer useful? Yes | No
January 02, 2007 06:25:39   #3  
R.Ravi Kumar        

RE: 1).please write an example of getting the smallest...

Q2) Actualy the date formate will be mm/dd/yyyy if we changed the formate to assaigned into date variable it will show formate error.

date variable will accept some foramate as per my knowledge.

--> If we assaigned 12/2000 formate date variable will take 12/1/2000 formate.

ex:

dim _date as date 12/2000

msgbox(_date) //output is 12/1/2000 by default it will take 1 day

--> If we assaigned 12/2000/31 fomate date variable will take 12/31/2000 formate

dim _date as date 12/2000/31

msgbox(_date) //output is 12/31/200

In Below example: we are removeing 31/ from 31/12/2000 formate and added that at lost of the word like : 12/2000/31 and finally i assaigned to date variable then as i said above that formate will be 12/31/2000 formte.

--------------

Dim _strdate_string As String 31/12/2000

_strdate_string Mid(_strdate_string _strdate_string.IndexOfAny( / ) + 2 _strdate_string.Length) + / + Mid(_strdate_string 1 _strdate_string.IndexOfAny( / ))

Dim _strdate As Date Convert.ToDateTime(_strdate_string)

MsgBox(_strdate) //out put 12/31/2000


 
Is this answer useful? Yes | No
January 02, 2007 06:28:17   #4  
R.Ravi Kumar        

RE: 1).please write an example of getting the smallest...

Q3)

If Date.Now.Month + 8 > 12 Then

MsgBox(Date.DaysInMonth(CType(Date.Now.Year + 1 Integer) Date.Now.Month + 8 - 12))

Else

MsgBox(CType(Date.DaysInMonth(Date.Now.Year Date.Now.Month + 8) String))

End If


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape