Hi
I have placed two datepicker and one text box in the form one as dt1 and another as dt2 if I select say 12/12/2007 in dt1 and 28/12/2007 in dt2 then in text1.text the number of days elapsed between the two days should be appeared.
So will any one write the code for VB6.

thanks in advance

Hi,

Try:

Text1.Text = DateDiff("d", DTPicker1.Value, DTPicker2.Value)

Regards,
Shrinivas

Hello Mr Shrinivas,
It is working but not as required by me. The code given by you gives 35 or 48 etc as the difference but I want it in days format like
if there is 35 days then it should show as 5/1/0 i.e one months five days I hope you got my point.

thanks

You might want to re-think the way you are trying to express the number of days (days/months/years). It gives inconsistant results, depending on the beginning and ending dates.

For example, 5/1/0 is 35 days if the beginning date is 3/4/2007 and the ending date is 8/5/2007, but if the beginning date 3/5/2007 and the ending date is 8/6/2007, 5/1/0 is 36 days.

Hoppy

its better write your own function for the purpose with all the formattings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.