By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,958 Members | 1,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,958 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Oct 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

DateTime.AddDays(-1)

Amanda wrote:
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
Oct 10 '06 #2

P: n/a

Truong Hong Thi wrote:
DateTime.AddDays(-1)
Thanks

Oct 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.