• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Need help in Visual Basic re: dates

Hi group. I'm stuck in writing a formula to add/subtract
dates (ie: 08/06/2005 - 08/06/2001).
Can someone pls. provide me with the formula or even a site to
look this up. Help is appreciated. Thanks.
 
You should just be able to use regular math ("+" and "-&quot😉 operators to do it (I think). If you're doing it in SQL there's probably a "dateadd" kind of function, but in straight VB I think
"Date1 - Date2" will work. If for some reason you get a date value as a result try casting it as a number.
 
Well fine then 🙂.

You could try "Month(date1) - Month(date2)". I found this in the interdev help, I can't remember actually having used it. I think the month function returns the month part (as an integer) of the date you give it. You could also just divide the days difference by 30. It wouldn't be exactly right but it would be pretty close.
 
on a related topic, could somebody tell me how to get the system date yesterday given today's date?
thanx all
whitecloak
 
will that work ( date -1 ) because date & 1 are different types. or will the compiler take care of it?
 
I always forget about datediff.

I think datediff will work for workerslacker (because he has both the dates and wants an interval between them), but not for whitecloak (because he doesn't have both dates).

All I can tell you about "Date - 1" is that it works in ASP VBscript. Just try it, I guess, and see what happens. SQL Server Transact-SQL has a function DATEADD, which does what you need to do, but if VB has an equivalent I don't know what it's called.
 
-1 wouldnt work too well because what if it was the 1st? You wouldn't know how many days were in the last month, or you could just make roll back to 30 or 31.
 
Back
Top