5 Replies - 4401 Views - Last Post: 02 July 2012 - 03:58 AM Rate Topic: -----

#1 raficomps1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-June 12

Question How to find total days between two date controls selection

Posted 30 June 2012 - 04:45 AM

 Protected Sub Calendar2_Selectionchanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar2.Selectionchanged
        Dim myDate1 As String = ""
        myDate1 = Calendar2.SelectedDate.ToShortDateString()
        txtLeaveFrom.Text = myDate1.Replace("-", "/")
        Dim div As System.Web.UI.Control = Page.FindControl("divCalendar1")
        If TypeOf div Is HtmlGenericControl Then
            CType(div, HtmlGenericControl).Style.Add("display", "none")
        End If
    End Sub
    Protected Sub Calendar3_Selectionchanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar3.Selectionchanged
        Dim myDate2 As String = ""
        myDate2 = Calendar3.SelectedDate.ToShortDateString()
        txtLeaveTo.Text = myDate2.Replace("-", "/")
        Dim div As System.Web.UI.Control = Page.FindControl("divCalendar2")
        If TypeOf div Is HtmlGenericControl Then
            CType(div, HtmlGenericControl).Style.Add("display", "none")
        End If
    End Sub



<asp:TableRow>
<asp:TableCell VerticalAlign="Middle" HorizontalAlign="Right"  Font-Size="Small" Font-Bold="True"Font-Italic="False" ForeColor="#3366CC" TabIndex="6">Total Days</asp:TableCell>
<asp:TableCell VerticalAlign="Middle" HorizontalAlign="Center">:</asp:TableCell>
<asp:TableCell VerticalAlign="Middle" HorizontalAlign="Left"  ><asp:TextBox ID="txtTotalDays" runat="server" Width="200px" Enabled="false" Font-Bold ="true" Font-Names ="Tahoma" Font-Size ="Small"></asp:TextBox></asp:TableCell>
</asp:TableRow>



Have to find total days from two date controls after selecting dates in two controls
it should print total days by calculating after immediate selection of second date control

Is This A Good Question/Topic? 0
  • +

Replies To: Question How to find total days between two date controls selection

#2 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: Question How to find total days between two date controls selection

Posted 30 June 2012 - 05:20 AM

use date time subtract method
Was This Post Helpful? 0
  • +
  • -

#3 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 224
  • View blog
  • Posts: 1,499
  • Joined: 16-March 11

Re: Question How to find total days between two date controls selection

Posted 30 June 2012 - 07:06 AM

And what are we supposed to do you work for you? We don't do homework here. What is the problem? Where are you getting this problem? What was the intended result before it became a problem?
Was This Post Helpful? 0
  • +
  • -

#4 Raficomps  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-March 12

Re: Question How to find total days between two date controls selection

Posted 02 July 2012 - 02:08 AM

View Posttrevster344, on 30 June 2012 - 07:06 AM, said:

And what are we supposed to do you work for you? We don't do homework here. What is the problem? Where are you getting this problem? What was the intended result before it became a problem?


If Me.txtTotalDays.Text = "" Then
            Dim d1, d2 As Date
            d1 = Me.txtLeaveFrom.Text
            d2 = Me.txtLeaveTo.Text

            Me.txtTotalDays.Text = CStr(d2.Subtract(d1).Days + 1)
        End If



Quote

Hai, sorry actually i forget to write this code in my previous coding............ i got the total days for that calendar control but the thing is after the selection of date in calendar3 it should find total days example:3/07/2012 - 5/07/2012 = 3 and if i give same date in both control it should show 1 in txttotalDays text box example 2/07/2012 - 2/07/2012=1

Was This Post Helpful? 0
  • +
  • -

#5 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 838
  • Joined: 21-December 11

Re: Question How to find total days between two date controls selection

Posted 02 July 2012 - 02:20 AM

Quote

Question How to find total days between two date controls selection

I don't know where is the problem
        Dim d1 As DateTime = Calendar1.Value
        Dim d2 As DateTime = Calendar2.Value
        Dim TotalDaysBetween As Integer = d2.Subtract(d1).Days

Was This Post Helpful? 0
  • +
  • -

#6 Raficomps  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 06-March 12

Re: Question How to find total days between two date controls selection

Posted 02 July 2012 - 03:58 AM

View Postsela007, on 02 July 2012 - 02:20 AM, said:

Quote

Question How to find total days between two date controls selection

I don't know where is the problem
        Dim d1 As DateTime = Calendar1.Value
        Dim d2 As DateTime = Calendar2.Value
        Dim TotalDaysBetween As Integer = d2.Subtract(d1).Days



Quote

Thank you sela007 i will try this

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1