Home All Groups Group Topic Archive Search About

How do I calculate the date of the previous day given a date ( in "MM/dd/yy" format)

Author
10 Oct 2006 10:13 AM
Amanda
This is hotel reservation when a departure date is changed manually by
user input ( to a valid date in date format - validity is
checkedsomewhere else), the arrival date is set to the previous date
upon MouseLeave. How do I calculate the date of the previous day  (see
mdatArrivalDate =  ???? )?

(I have already done calculating departure date when an arrrivalDate is
modified manually - not via selecting on calendar - to valid data by
usind AddDay(1).)

Any help?



Private Sub txtADepartureDate_KeyPress(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles _
    txtDepartureDate.KeyPress

   If txtDepartureDate.Modified Then

     If Not IsDate(txtDepartureDate.Text) Then
        txtDepartureDate.Text = mdatDepartureDate.ToString
      Else
        mdatDepartureDate = CDate(txtDepartureDate.Text)

        mdatArrivalDate =  ???? (I need the date of previous day )

        mshrNightStayed = 1
        txtArrivalDate.Text = mdatArrivalDate.ToString
      End If 'Not IsDate(txtDepartureDate.Text)

    End If ' txtDepartureDate.Modified

End Sub

Author
10 Oct 2006 10:31 AM
Truong Hong Thi
DateTime.AddDays(-1)

Amanda wrote:
Show quoteHide quote
> This is hotel reservation when a departure date is changed manually by
> user input ( to a valid date in date format - validity is
> checkedsomewhere else), the arrival date is set to the previous date
> upon MouseLeave. How do I calculate the date of the previous day  (see
> mdatArrivalDate =  ???? )?
>
> (I have already done calculating departure date when an arrrivalDate is
> modified manually - not via selecting on calendar - to valid data by
> usind AddDay(1).)
>
> Any help?
>
>
>
> Private Sub txtADepartureDate_KeyPress(ByVal sender As Object, _
>     ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles _
>     txtDepartureDate.KeyPress
>
>    If txtDepartureDate.Modified Then
>
>      If Not IsDate(txtDepartureDate.Text) Then
>         txtDepartureDate.Text = mdatDepartureDate.ToString
>       Else
>         mdatDepartureDate = CDate(txtDepartureDate.Text)
>
>         mdatArrivalDate =  ???? (I need the date of previous day )
>
>         mshrNightStayed = 1
>         txtArrivalDate.Text = mdatArrivalDate.ToString
>       End If 'Not IsDate(txtDepartureDate.Text)
>
>     End If ' txtDepartureDate.Modified
>   
>  End Sub
Author
10 Oct 2006 11:22 AM
Amanda
Truong Hong Thi wrote:
> DateTime.AddDays(-1)

Thanks