code to add 15 days to a given date.

Thread Solved

Join Date: Jun 2008
Posts: 33
Reputation: chanthung is an unknown quantity at this point 
Solved Threads: 0
chanthung's Avatar
chanthung chanthung is offline Offline
Light Poster

code to add 15 days to a given date.

 
0
  #1
Jun 24th, 2008
M writing a program to display the date ie. 15 days later after a given (present/todays)date.
Wel its actually like this. As soon as i write todays date, in the next text box, the date shd be automatically displayed adding 15 days to the present date which is already displayed.
Eg. supose i enter 01/06/2008 (dd/mm/yyyy), it shud automatically display 15/06/2008.
M trying to use
Datediff() function, but i dont know how to go about.

can anyone plz help me with the code..?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 1
Reputation: nagasai is an unknown quantity at this point 
Solved Threads: 1
nagasai nagasai is offline Offline
Newbie Poster

Re: code to add 15 days to a given date.

 
0
  #2
Jun 24th, 2008
In C#:

string strDate = "20/10/1983";
DateTime date = DateTime.Parse(strDate);
string newDate = date.AddDays(15).ToShortDateString();
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: code to add 15 days to a given date.

 
0
  #3
Jun 24th, 2008
Hi,

Use DateAdd function

  1. Dim TDate As Date
  2. TDate = CDate("01-06-2008")
  3. MsgBox DateAdd("d", 15, TDate)

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: code to add 15 days to a given date.

 
0
  #4
Jun 24th, 2008
Similar to Veena, I give another way

  1. Dim TDate As Date
  2. TDate = Date
  3. MsgBox TDate + 15
Still same result

Note:
Date object plus number will work only for days addition, but DateAdd() function will work for any interval
Last edited by selvaganapathy; Jun 24th, 2008 at 12:27 pm.
KSG
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 33
Reputation: chanthung is an unknown quantity at this point 
Solved Threads: 0
chanthung's Avatar
chanthung chanthung is offline Offline
Light Poster

Re: code to add 15 days to a given date.

 
0
  #5
Jun 25th, 2008
Thanks lots to all of u for help. M on it right away. Actually i'll be taking the date from the user tru da text box (n tn accept it in a string i suppose..)and try to add using the DateAdd function. The new date will be displayed in the next textbox. So after say 15 days it shud display a msg or change the background color i gs. M using Grid Control layout to display the Datas. MS Access is my database.

Have a Wonderful day ahead!!!!
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 33
Reputation: chanthung is an unknown quantity at this point 
Solved Threads: 0
chanthung's Avatar
chanthung chanthung is offline Offline
Light Poster

Re: code to add 15 days to a given date.

 
0
  #6
Jun 25th, 2008
made it this way.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Text5_Lostfocus()
  2. Dim PDate, RDate As Date
  3. PDate = CDate(Text5.Text)
  4. RDate = DateAdd("d", 15, PDate)
  5. Text6.Text = RDate
  6. End Sub
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC