|
-
Jul 30th, 2001, 07:11 AM
#1
Thread Starter
Hyperactive Member
DateDiff problem
In Authorware there is the function "DateToNum" here are the specifications:
number := DateToNum(day; month; year)
DateToNum converts a date (day, month, and year) to a number that corresponds to the number of days since January 1, 1900. This function performs the opposite calculation from the Date function, which converts a number to a date. The following table shows the range of valid dates:
Windows: 1, 1, 1970, to June, 2, 2036 (25568 to 49709)
Macintosh: 1, 1, 1904, to June, 2, 2040 (1461 to 51171)
I tried to code it in vb (asp actually) but it is not the same :
function DateToNum(dtDate)
dim strStartDate, dtStartDate
strStartDate = "January 1, 1900"
dtStartDate = DateValue(strStartDate)
DateToNum = DateDiff("d",dtStartDate,dtDate)
end function
1/1/1970 produces 25568 in authorware but 25567 in my routine.
How can I make the routine work for me ?
-
Jul 30th, 2001, 07:15 AM
#2
Hyperactive Member
DateToNum = DateDiff("d",dtStartDate+1,dtDate)
-
Jul 30th, 2001, 07:17 AM
#3
try this:
VB Code:
Private Sub Command1_Click()
MsgBox DateToNum("01/01/1970")
End Sub
Public Function DateToNum(pDate As Date) As Long
Dim lngDate As Long
lngDate = pDate
DateToNum = lngDate
End Function
-
Jul 30th, 2001, 07:44 AM
#4
Thread Starter
Hyperactive Member
Both solutions do not produce equivalent output. I converted nullus's routine to asp:
function DateToNum(dtDate)
Dim lngDate
lngDate = CLng(CDate(dtDate))
DateToNum = lngDate
end function
however this gives me 25569 for 1/1/1970, while the authorware routine returns 25568.
inserting "June 2, 2036" returns 49828 while in authorware it returns 49709.
-
Jul 30th, 2001, 10:22 AM
#5
Thread Starter
Hyperactive Member
It works... Authorware goes beserk out of the bounds of 1970, 2036.. Here's my code :
function DateToNum(dtDate)
Dim lngDate
lngDate = CLng(CDate(dtDate))
DateToNum = lngDate-1
end function
function NumToDate(lngNumDate)
dim dtDate
dtDate = Cdate(CLng(lngNumDate))
NumToDate = dtDate+1
end function
Response.Write DateToNum("September 5, 2002")
Response.Write "<br />"
Response.Write NumToDate(37503)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|