ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Number of days between dates (Calendar) (https://www.excelbanter.com/excel-programming/276449-number-days-between-dates-calendar.html)

Malcolm

Number of days between dates (Calendar)
 
Hi

I have a form that has 2 calendars on it. Calendar1 is
going to be used to select a date "FROM" and Calendar2 is
going to be used to select a date "TO" with the number of
days appearing in a text box.

For instance, if Calendar1 said Sept 3 2003 and Calendar2
said Sept 4 2003, the text box would have the value 1 in
it. I can do this to a degree, but if I was to select 31
Aug 2002 in Calendar1 and 31 Aug 2003 in Calendar2, the
text box says 0 instead of 366, which would be the number
of days between the 2 dates.

Any ideas

Thanks in advance

Malcolm Davidson

Tom Ogilvy

Number of days between dates (Calendar)
 
Dim cDate1 as Date, cDate2 as Date
cdate1 = Calendar1.Value
cdate2 = Calendar2.Value

Textbox1.Value = format(cdate2 - cdate1,"#0")

--
Regards,
Tom Ogilvy


"Malcolm" wrote in message
...
Hi

I have a form that has 2 calendars on it. Calendar1 is
going to be used to select a date "FROM" and Calendar2 is
going to be used to select a date "TO" with the number of
days appearing in a text box.

For instance, if Calendar1 said Sept 3 2003 and Calendar2
said Sept 4 2003, the text box would have the value 1 in
it. I can do this to a degree, but if I was to select 31
Aug 2002 in Calendar1 and 31 Aug 2003 in Calendar2, the
text box says 0 instead of 366, which would be the number
of days between the 2 dates.

Any ideas

Thanks in advance

Malcolm Davidson





All times are GMT +1. The time now is 11:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com