Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date to Number

Status
Not open for further replies.

Esoteric

ISP
Feb 10, 2001
93
US
I have a need to convert the date to a number.

ie:
<PARAM NAME=&quot;CurrentDate&quot; VALUE=&quot;37291&quot;>
<PARAM NAME=&quot;MaxDate&quot; VALUE=&quot;2958465&quot;>
<PARAM NAME=&quot;MinDate&quot; VALUE=&quot;-109205&quot;>

I want to insert a given date into the &quot;CurrentDate&quot; how do I convert a date ie: 2/2/2002 into a number like above.
 
We-ell, I'll assume we are talking about the date (integer number) part of a Variant &quot;date/time&quot; value.

You can use CLng({date value}) as in:
Code:
Option Explicit

Sub ShowMeDate(lngNum)
  Dim dtDate

  dtDate = CDate(lngNum)
  MsgBox dtDate & &quot; = &quot; & CStr(lngNum)
End Sub

Sub ShowMeNum(dtDate)
  Dim lngNum

  lngNum = CLng(dtDate)
  MsgBox CStr(lngNum) & &quot; = &quot; & dtDate
End Sub

ShowMeNum(Date())
ShowMeNUm(#3/11/1945#)

ShowMeDate(12345)
ShowMeDate(-109205)
Is this what you had in mind?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top