473,398 Members | 2,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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

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
2 1480

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

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

Oct 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Matt | last post by:
My ASP page allows the user select the date, and it will display the report during that week of that date. My question is when the program query database, I need to know the beginning date and...
8
by: Dennis M. Marks | last post by:
What is the maximum valid date range for the date(yyyy,mm,dd) function. -- Dennis M. Marks http://www.dcs-chico.com/~denmarks/ Replace domain.invalid with dcsi.net -----= Posted via...
7
by: AdityaK | last post by:
Is there a way to find Weekend date for a given date using a DB2 query? I see that there are scalar functions such as DAY, DAYOFMONTH, DAYOFWEEK,etc are available...but couldn't find one to get a...
5
by: Hardy Wang | last post by:
Hi: Are there any algorithms I can use, that based on a given date and a culture code (different cultures may have different beginning of week), I can get first and last date of the current week?...
1
by: abcabcabc | last post by:
I write an application which can let user define own date format to input, How to convert the date string to date value with end-user defined date format? Example, User Defined Date Format as...
4
by: perryclisbee via AccessMonster.com | last post by:
I have dates of service for several people that range all over each month. ie: patient had dates of service of: 7/3/2006, 7/24/2006 and 7/25/2006. I need to create a new field via a query that...
4
by: IsdWeb | last post by:
Hello, I am a newbie to coding and need some help. I am trying to figure out why the following code is not producing the correct Julian date. Any suggestions? Also, I am trying to understand...
4
by: Tony B | last post by:
I'm looking to convert a string in "dd/MM/yy" format into a date object. How do I go about this ?
5
OuTCasT
by: OuTCasT | last post by:
Hi. I would like to know how to convert the short date format to the long date format for my application without changing the regional settings from short date to long date. ?
2
Soniad
by: Soniad | last post by:
Hi, In my website, I show commodity details on daily basis.These details are stored in one table for each day. I select record by matching current date and current date records are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.