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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datepart

Status
Not open for further replies.

supermaestro

Programmer
Dec 18, 2002
15
0
0
GB
Can anybody tell me why I get an 'invalid procedure, call or argument' error for this:

DatePart("dd", yearEndTo)

when DatePart("d", yearEndTo)is fine? I need to return a two digit day number for the date yearEndTo.

Thanks
 
Hey, me again... Yeah, the "dd" isn't supported in the datepart function as it is in the format function. So you'd have to create a "date" string like "1/1/2002" first, then format it like"

YearEndTo = Format(YearEndTo,"dd/mm/yyyy")

Then either wrap it with # signs or use CDate() to make it a date:

Since YearDateTo is dimmed as a string, you'd have to have another variable dimmed as Date type in order to store the result of:

YearEndToDate = CDate(YearEndTo)

I think you could do this all in one step:

YearEndToDate = CDate(Format(YearEndTo,"dd/mm/yyyy"))

To REALLY do it all in one step, create your initial "1/3/2003 format in the above statement in place of "YearEndTo".

Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top