PDA

View Full Version : [SOLVED:] DateDiff in listview excel



djemy1975
04-17-2016, 03:10 AM
Dear developpers,

Please help me to do some calculations in order to track payment of invoices:

Here are the rules:


Payment périod is 60 days
"Date échéance" = "date dépôt"+60 days
"Reste"=today - date échéance

I want also when I click commandbutton2 to populate date échéance in listview and sheet BDD from textbox9


Thanks in advance,

SamT
04-17-2016, 04:25 PM
échéance = DateAdd("D", 60, dépôt)
Reste =DateDiff("D", Date, échéance) 'Negative Result = days late

djemy1975
04-18-2016, 11:53 AM
échéance = DateAdd("D", 60, dépôt)
Reste =DateDiff("D", Date, échéance) 'Negative Result = days late

Thank you for your reply .

I added the code like that:
TextBox9 = DateAdd("D", 60, TextBox8)
TextBox10 = DateDiff("D", Date, TextBox9) 'Negative Result = days late
but it seems not functionning well

SamT
04-18-2016, 12:57 PM
TextBox values are strings.
DateAdd and DateDiff results are numbers.

TextBox9 = Cstr(DateAdd("D", 60, CDate(TextBox8)))
TextBox10 = CStr(DateDiff("D", Date, CDate(TextBox9)))

djemy1975
04-18-2016, 01:16 PM
TextBox values are strings.
DateAdd and DateDiff results are numbers.

TextBox9 = Cstr(DateAdd("D", 60, CDate(TextBox8)))
TextBox10 = CStr(DateDiff("D", Date, CDate(TextBox9)))
Thank you very much .It is exactly what I need .
Can you tell me how to format textbox9 as date like this:Format(TextBox9.Value, "dd mmm yyyy") in this calcualtion as it gives result as 09/06/2016 .I want to show it 09 juin 2016.
Also,how about

I want also when I click commandbutton2 to populate date échéance in listview and sheet BDD from textbox9

Thanks in advance,

SamT
04-18-2016, 06:48 PM
I want to show it 09 juin 2016.
09 January 2016 = Format String = "dd mmmm yyyy"
09 Jan 2016 = "dd mmm yyyy"

Format returns a String like CStr does.

TextBox9 = Format(DateAdd("D", 60, CDate(TextBox8)), "dd mmmm yyyy")
This is a onion with the value of TextBox8, a String, at the core. = strTB8

First layer of the onion: Convert strTB8 to a Date: CDate(strTB8) = dteTB8
Next Layer: Add 60 days to that Date: DateAdd("D", 60, dteTB8) = dte60
Finally, Format dte60 to a String the way you want: Format(dte60, "dd mmmm yyyy") =strDate60
Only then do you give it to the Control: TextBox9 = strDate60

djemy1975
04-19-2016, 01:12 AM
09 January 2016 = Format String = "dd mmmm yyyy"
09 Jan 2016 = "dd mmm yyyy"

Format returns a String like CStr does.

TextBox9 = Format(DateAdd("D", 60, CDate(TextBox8)), "dd mmmm yyyy")
This is a onion with the value of TextBox8, a String, at the core. = strTB8

First layer of the onion: Convert strTB8 to a Date: CDate(strTB8) = dteTB8
Next Layer: Add 60 days to that Date: DateAdd("D", 60, dteTB8) = dte60
Finally, Format dte60 to a String the way you want: Format(dte60, "dd mmmm yyyy") =strDate60
Only then do you give it to the Control: TextBox9 = strDate60


Thank you for the time you have given to provide me with this valuable solution

So proud of you ...