VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



To calculate number of days elapsed between two dates. (Using Julian Date Method)

by Keshav Mantha (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 24th August 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

To calculate number of days elapsed between two dates. (Using Julian Date Method)

API Declarations


'
'
'

Rate To calculate number of days elapsed between two dates. (Using Julian Date Method)



*
pmmdd1 = substr(porgdt1,5,4)
pmmdd2 = substr(porgdt2,5,4)
*
n_mmdd1 = val(pmmdd1)
n_mmdd2 = val(pmmdd2)
*
pyy1 = substr(porgdt1,1,4)
pyy2 = substr(porgdt2,1,4)
*
n_yy1 = val(pyy1)
n_yy2 = val(pyy2)
*
pmm1 = substr(porgdt1,5,2)
pmm2 = substr(porgdt2,5,2)
*
n_mm1 = val(pmm1)
n_mm2 = val(pmm2)
*
sk_juldt()
*
retu
***
FUNCTION sk_juldt
*
sele b
use judb inde jmmdd
seek n_mmdd1
  if found()
     n_days1 = jday
  endi
seek n_mmdd2
  if found()
     n_days2 = jday
  endi        
*
if n_yy2 > n_yy1
   if (n_yy2 - n_yy1) > 1
      days = days + 365*(n_yy2 - n_yy1 - 1)
      if n_mm2 = n_mm1
         if n_days2 > n_days1
            days  = days + (n_days2 - n_days1) + 365        
 endi
 if n_days2 = n_days1
    days = days + 365
 endi
 if n_days2 < n_days1
            days  = days + (365 - (n_days1 - n_days2))        
 endi   
      endi
      if n_mm2 > n_mm1
         days  = days + (n_days2 - n_days1) + 365     
      endi  
      if n_mm2 < n_mm1
         days = days + n_days2 + (365 - n_days1)
      endi
   endi
   if (n_yy2 - n_yy1) = 1
      if n_mm2 = n_mm1
         if n_days2 > n_days1
            days  = days + (n_days2 - n_days1) + 365        
 endi
 if n_days2 = n_days1
    days = days + 365
 endi
 if n_days2 < n_days1
            days  = days + (365 - (n_days1 - n_days2))        
 endi
      endi
      if n_mm2 > n_mm1
         days  = days + (n_days2 - n_days1) + 365     
      endi  
      if n_mm2 < n_mm1
         days = days + n_days2 + (365 - n_days1)
      endi   
   endi
endi   
if n_yy2 = n_yy1   
   if (n_mm2 > n_mm1) .or. (n_mm2 = n_mm1)
      days  = days + (n_days2 - n_days1)      
   endi
endi   
retu days


Download this snippet    Add to My Saved Code

To calculate number of days elapsed between two dates. (Using Julian Date Method) Comments

No comments have been posted about To calculate number of days elapsed between two dates. (Using Julian Date Method). Why not be the first to post a comment about To calculate number of days elapsed between two dates. (Using Julian Date Method).

Post your comment

Subject:
Message:
0/1000 characters