uttar's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
23 (0.03 per day)
Joined:
28-October 12
Profile Views:
1,459
Last Active:
User is offline May 27 2013 09:29 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   uttar has not set their status

Posts I've Made

  1. In Topic: if else in datetime in vb.net

    Posted 10 Dec 2012

    View Postlar3ry, on 09 December 2012 - 10:54 PM, said:

    Quote

    if i have 1 months 1 days..my output is 1 months 2 days..but if i have 1 year 1 day, i display the right result which is 1 year 1 days..or 1 year 3months 1 day output is 1 year 3months 2 days..

    how come i get 2 days..really need your help.

    I tested your code (Function RaceDate), and if I pass it 31, it returns "1 Months 1 Days", and if I pass it 456, it returns "1 Years 3 Months 1 Days".

    So, where's the problem?



    hi

    thanks for your reply...


    i enter 1 year 3months 1 day..and it return 1 year 3months 2 days...if i enter 2 days it returns 2 days..1 year 2days it return 1 year 2days but if i enter 3 months 2 days it return 3months 3 days...that's my problem now

    thanks

    View Posttrevster344, on 09 December 2012 - 10:05 PM, said:

    Place a break point. Do you know how to do that?


    hi trevster344,

    dont know how to do that..is it same as to comments?

    thanks
  2. In Topic: if else in datetime in vb.net

    Posted 9 Dec 2012

    View Postnilkanthnaik5, on 29 November 2012 - 11:01 PM, said:

    Hi uttar.
    I am answering your first question.
    I am giving you 2 solutions.
    I think 1st is better.
    Try first solution:-


    Public Function GetCustomDate(ByVal days As Int32) As String
            Dim objDate1 As DateTime = DateTime.Now()
            Dim objDate2 As DateTime = objDate1.AddDays(-1 * days)
            Dim str1, str2, str3, strfinal As String
            str1 = (objDate1.Year - objDate2.Year) & " Years"
            str2 = (objDate1.Month - objDate2.Month) & " Months"
            str3 = (objDate1.Day - objDate2.Day) & " Days"
            If str1 <> "0 Years" Then
                strfinal = strfinal + str1
            End If
    
            If str2 <> "0 Months" Then
                strfinal = strfinal + str2
            End If
            If str3 <> "0 Days" Then
                strfinal = strfinal + str3
            End If
    
            Return strfinal
    End Function
    
    



    Try Second solution:-

    Public Function GetCustomDate(ByVal days As Int32) As String
    
    Dim objDate1 As DateTime = DateTime.Now()
    Dim objDate2 As DateTime = objDate1.AddDays(-1 * days)
    
    If (objDate1.Year - objDate2.Year) <> 0 And (objDate1.Month - objDate2.Month) <> 0 And (objDate1.Day - objDate2.Day) <> 0 Then
                Return (objDate1.Year - objDate2.Year) & "Years" & (objDate1.Month - objDate2.Month) & "Months" & (objDate1.Day - objDate2.Day) & " Days"
     
    ElseIf (objDate1.Year - objDate2.Year) = 0 And (objDate1.Month - objDate2.Month) <> 0 And (objDate1.Day - objDate2.Day) <> 0 Then
                Return (objDate1.Month - objDate2.Month) & "Months" & (objDate1.Day - objDate2.Day) & " Days"
    
    ElseIf (objDate1.Year - objDate2.Year) <> 0 And (objDate1.Month - objDate2.Month) = 0 And (objDate1.Day - objDate2.Day) <> 0 Then
                Return (objDate1.Year - objDate2.Year) & "Years" & (objDate1.Day - objDate2.Day) & " Days"
    
    ElseIf (objDate1.Year - objDate2.Year) <> 0 And (objDate1.Month - objDate2.Month) <> 0 And (objDate1.Day - objDate2.Day) = 0 Then
                Return (objDate1.Year - objDate2.Year) & "Years" & (objDate1.Month - objDate2.Month) & "Months"
    
    ElseIf (objDate1.Year - objDate2.Year) <> 0 And (objDate1.Month - objDate2.Month) = 0 And (objDate1.Day - objDate2.Day) = 0 Then
                Return (objDate1.Year - objDate2.Year) & "Years"
    
    ElseIf (objDate1.Year - objDate2.Year) = 0 And (objDate1.Month - objDate2.Month) <> 0 And (objDate1.Day - objDate2.Day) = 0 Then
                Return (objDate1.Month - objDate2.Month) & "Months"
    
    ElseIf (objDate1.Year - objDate2.Year) = 0 And (objDate1.Month - objDate2.Month) = 0 And (objDate1.Day - objDate2.Day) <> 0 Then
                Return (objDate1.Day - objDate2.Day) & " Days"
    
    ElseIf (objDate1.Year - objDate2.Year) = 0 And (objDate1.Month - objDate2.Month) = 0 And (objDate1.Day - objDate2.Day) = 0 Then
                Return (objDate1.Day - objDate2.Day) & " Days"
    End If
    
    End Function
    
    



    if i have 1 months 1 days..my output is 1 months 2 days..but if i have 1 year 1 day, i display the right result which is 1 year 1 days..or 1 year 3months 1 day output is 1 year 3months 2 days..

    how come i get 2 days..really need your help.

    Public Function RaceDate(length  As Integer ) As String
            
                 dim year As string=0
                 dim month As string=0
                dim day As string=0
                 dim ReturnString As string
    
    ReturnString=""
    
    If length = 0 then
    Return String.Empty
    end if
    
    
    
    if length >=365
    year=cstr((Math.Floor (length / 365)))
    length  =(length  Mod 365)
    
    end if
    
    If length >=30 AndAlso length<365 Then
    month =(cstr((Math.Floor(length/30))))
    length  =(length  Mod 30)
    
    end if
    
    if length<=30 Then
    day =cstr((length))
    
    end if
    
    if cint(year)>0
    
    ReturnString= year+"  Years  "
    
    end if
    
    if cint(month)>0
    
    ReturnString= ReturnString +month+" Months "
    
    end if
    
    if cint(day)>0
    
    ReturnString=ReturnString+day+"  Days "
    end if
    
    return(ReturnString)
    
    end Function
    
  3. In Topic: if else in datetime in vb.net

    Posted 30 Nov 2012

    hi nilkanthnaik5,

    thanks for your reply..i was being able to solve it as dong some changes.i go for the 1st solution above as my reference..

    Many thanks
  4. In Topic: if else in datetime in vb.net

    Posted 28 Nov 2012

    hi

    if i got 230days it should be 7months 20days but i got 7 months 16days its not give me d the right result in days.but this problem always happens to my days only and not years and months,secondly my days too got negative for some like


    
    Public Function XX(ByVal days As integer) As String
            
         Dim objDate2 As DateTime = objDate1.AddDays(-1* days)    
         dim result as String=0
    
            If Not (objDate1.Day - objDate2.Day)=0  Then
                result += (objDate1.Day - objDate2.Day) & " Days "
                 'result+
            End If
    
            Return result.Trim()
    
    
    


    thanks in advance
  5. In Topic: add sum and Average outside if statement

    Posted 8 Nov 2012

    hi lar3ry,

    thanks for your patience in reading my question and answers. able to solve it.. :)

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

uttar has no profile comments yet. Why not say hello?