Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,

Can you help me in how to Subtract a given date from an given integer with a format of a "MM/DD/YYYY"?

Please help me ....

Thanks in Advance...
Posted
Updated 12-Jun-10 6:20am
v2

jleonorlane wrote:
Subtract a given date from an given integer


How come a date can be substracted from an integer? Both are totally different datatypes.

Looks like you want to substract integer number of days from a given date, if so, do something like:
myDate.AddDays(-1*numberToDeduct);

Converting date in a particular format, do like:
(Convert.ToDateTime(myDate)).ToString("MM/dd/yyyy");
 
Share this answer
 
If the integer represents days,

VB
Dim x As New Date
Dim i As Integer = 0
Dim xdays = TimeSpan.FromDays(x.TimeOfDay.Days)
Dim idays = TimeSpan.FromDays(i)
Dim diff = (xdays - idays)
 
Share this answer
 
You might want to have a look at this and this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900