-
April 7th, 2011, 02:22 AM
#1
Calculating number of days from DatePicker
Halo,
My application captures data using date pickers. Items are taken and returned after certain intervals.
I have code that should change the date in DTPicker2 by 21 days if DTPicker1 has been changed.
Code:
Private Sub
Dim d As String, dtp As Date
dtp=DateAdd("d", 21, Now)
DTPicker2.Value = dtp
End Sub
ONE: This code at times simply changes the value of the date bot not the month, is there a better code than this(for achieving my goal of adding 21 days to the days given)? I searched this forum and tried all the proposed ones and even tried modifying them but none seems to be working for me.
TWO: Items should be returned on or before the DTPicker2.Value has elapsed. I want to querry the database to know what items have not been returned as at today... am stuck. Any ideas out there on how to calculate the duration an item has been out?
-
April 7th, 2011, 11:43 AM
#2
Re: Calculating number of days from DatePicker
You are adding 21 days to TODAY, not the date picked day.
-
April 7th, 2011, 04:09 PM
#3
Re: Calculating number of days from DatePicker
when querying a database I usually add one day because in date terms, if you set MyDate = "4/4/2011" It's Set to '4/4/2011 12:00am' or Midnight at the start of the day..
When Querying a DB on Day time '4/4/2011 8:00am' is > Mydate and not < Mydate...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
April 11th, 2011, 05:06 AM
#4
Re: Calculating number of days from DatePicker
Originally Posted by dglienna
You are adding 21 days to TODAY, not the date picked day.
So where do I set it to pick the date on the DTPicker1? Do I have an extra line with
Code:
myPickDate=DTPicker1.Value
-
April 11th, 2011, 05:10 AM
#5
[resolved] Re: Calculating number of days from DatePicker
Thanks for the light bulb. This is what I did and so far it counts 21 days fine.
Code:
Private Sub DTPicker1_Change()
Dim d As String, dtp As Date, myPickDate As Date
myPickDate = DTPicker1.Value
dtp = DateAdd("d", 21, myPickDate)
DTPicker2.Value = dtp
End Sub
Last edited by iagina; April 11th, 2011 at 05:14 AM.
Reason: Extra line in code
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|