Results 1 to 2 of 2
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DateDiff (VBScript 5.5)

    Hello all,
    I am using a vbscript file within an application for a piece of equipment we manufacture. The scripting language is 5.5 and I am using a datediff function to return the day number of the year. I have it working but I would like the first date of the calculation to be Jan 1 of that year. Is there a way to make that date entry automatically? In other words, I don't want to have the operator going into the script file to change the date on Jan 1st. Any ideas?

    Thanks,
    Mark

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: DateDiff (VBScript 5.5)

    <P ID="edit" class=small>(Edited by JohnBF on 09-Nov-04 09:10. Made second function simpler. Why'd I make it unnecessarily complicated to begin with?)</P>If "that year" is always the current year, try

    dayofyear = DateDiff("d", DateSerial(Year(Date), 1, 0), Date)

    If the date is in some other year, use

    dayofyear = DateDiff("d", DateSerial(Year(someotherdate), 1, 0), someotherdate)

    HTH.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •