Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions

Meet Caitlin Cunningham, Entry Level Senior Recruiter

Reply
 
Thread Tools Display Modes
  #1  
Old 02-07-2002, 08:52 AM
Jovial Guan Jovial Guan is offline
 
Join Date: Jan 2002
Posts: 13
Default

I want to use Visual Basic to calculate the days between the two dates. For example, the issue day is 2001-3-5, the valuation day is 2002-1-31, then what's the days between these two days? I try to use the function "Datediff", but the answer is always negative. Thank you very much.
Reply With Quote
  #2  
Old 02-07-2002, 10:31 AM
Gates Is Antichrist's Avatar
Gates Is Antichrist Gates Is Antichrist is offline
Member
SOA AAA
 
Join Date: Feb 2002
Location: Hell
Favorite beer: Pacifico
Posts: 156
Default

You refer to Excel so I assume you mean VBA, vs. VB. In Excel there is no function "Datediff" although there is a "DATEDIF" (which to my knowledge can not return a negative value).

If you'd like to try again, I may be able to help. Sorry, I know it's a b**ch, but I think the upshot here is...amazingly enough, accuracy is a requisite aspect of using computers.

<font size=-1>[ This Message was edited by: Gates Is Antichrist on 2002-02-07 10:38 ]</font>

<font size=-1>[ This Message was edited by: Gates Is Antichrist on 2002-02-07 10:39 ]</font>
Reply With Quote
  #3  
Old 02-07-2002, 10:51 AM
General Kenobi (ret.) General Kenobi (ret.) is offline
Member
 
Join Date: Sep 2001
Location: More powerful than you can possibly imagine
Posts: 1,031
Default

Have you tried reversing the arguments? Or just sticking a negative sign in front?
Reply With Quote
  #4  
Old 02-07-2002, 12:05 PM
Dr T Non-Fan Dr T Non-Fan is offline
Member
 
Join Date: Sep 2001
Location: Just outside of Nowhere
Posts: 59,131
Default

Is it necessary to use VB?
In a cell, you can just subtract the dates, no questions asked.

From Excel's VB help:
"Syntax

DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])"

Later on:
"If date1 refers to a later point in time than date2, the DateDiff function returns a negative number."

To make them positive, the dates should be listed in the function in chronological order.
Reply With Quote
  #5  
Old 02-07-2002, 12:36 PM
Anonymous
Guest
 
Posts: n/a
Default

If you're truly referring to VB, like in a macro, then you just need to define your variables as a date type (i.e. ValDate as Date). VB will accept standard date formats into the date type like "01/01/2002". Then just subtract your variables to get the number of days between dates.
Reply With Quote
  #6  
Old 02-07-2002, 03:37 PM
Gates Is Antichrist's Avatar
Gates Is Antichrist Gates Is Antichrist is offline
Member
SOA AAA
 
Join Date: Feb 2002
Location: Hell
Favorite beer: Pacifico
Posts: 156
Default

Quote:
On 2002-02-07 10:51, Obi-Wan Kenobi wrote:
Have you tried reversing the arguments? Or just sticking a negative sign in front?
I stand corrected. F@$#%ing computers and that carefulness and accuracy thing! :emb:

Thy master spake the truth, Young Luke.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 04:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.18133 seconds with 7 queries