473,387 Members | 1,529 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,387 software developers and data experts.

DateDiff Function

I need help with what to write for my DateDiff Function to work properly between two datetimepicker boxes to give 'days' results. This is what I have and it works except I can't have the intDate1 to be specific and intDate2 as Now. I need to make it work so when the second date is chosen it gives the days between current date in intDate1 and date selected in intDate2.

Help Please??

Expand|Select|Wrap|Line Numbers
  1.   Dim intDiff As Integer
  2.         Dim intDate1 As String
  3.         Dim intDate2 As String
  4.         intDate1 = "01/01/2007"
  5.         intDate2 = "Now"
  6.         intDiff = DateDiff("d", "01/01/2007", Now())
  7.         TxtBox1Days.Text = intDiff
Feb 16 '07 #1
3 3020
samycbe
83
Dear Friend.

Step1 : Create 1 datepicker and one 1 command button in a form
step 2 : select any date in datepicker1
step 3 : write following code in command1_click

Dim a As Double
a = DateDiff("d", DTPicker1, Date)
MsgBox a

is it ok

samy
Feb 17 '07 #2
Use CDate(string) function to convert string to date.

Padmini.
Mar 6 '07 #3
vijaydiwakar
579 512MB
I need help with what to write for my DateDiff Function to work properly between two datetimepicker boxes to give 'days' results. This is what I have and it works except I can't have the intDate1 to be specific and intDate2 as Now. I need to make it work so when the second date is chosen it gives the days between current date in intDate1 and date selected in intDate2.

Help Please??

Expand|Select|Wrap|Line Numbers
  1.   Dim intDiff As Integer
  2.         Dim intDate1 As String
  3.         Dim intDate2 As String
  4.         intDate1 = "01/01/2007"
  5.         intDate2 = "Now"
  6.         intDiff = DateDiff("d", "01/01/2007", Now())
  7.         TxtBox1Days.Text = intDiff
just try this with one change as
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim intDiff As Integer
  3. dim intDiff%
  4.         intDiff = DateDiff("d", dtp1.value, dtp2.value)
  5.         TxtBox1Days.Text = intDiff
  6.  
Mar 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: News Central | last post by:
To all! I use the DateDiff function using VB6 and get this error 'Wrong number of argument or invalid property assignment' ... have anyone seen this problem? thanks ....
7
by: Drago | last post by:
Hi, I got the next question, I want to know the diference between two dates and thats is really easy, but my problem is get that diference in the following format ex. "the diference is= 0 year,...
6
by: Lofty | last post by:
Hi all. I have to write an app that interacts with mySQL (I really must have done some evil, evil stuff in a previous life to be landed with this!) I need to work out the difference in days...
1
by: intl04 | last post by:
I'm trying to set up a query that will include a new field ('Days until completion') whose value is derived from the DateDiff function. I think I have the syntax correct but am not sure. Days...
4
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS...
1
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a...
5
by: mcbill20 | last post by:
Hello all. I have a really basic question that I hope someone has a better answer for. I apologize in advance-- I know this is probably a really basic question but I am used to Oracle rathern than...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
6
by: kevinjwilson | last post by:
I am trying to get the date difference between two dates but I don't want the function to include weekends in the calculation. Does anyone have an idea on how to make this work?
2
by: muddasirmunir | last post by:
i am using vb 6 , i had place two datepicker in form now i want to calcuate differcen of month in two date for this i used the function datediff i had try it withh many syntax but getting error...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.