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

Help with Syntax date = (#3/1/2009#)

Status
Not open for further replies.

osx99

Technical User
Apr 9, 2003
250
GB
I have a macro which runs by changing specified date as follows

[code/]
datetoextract = (#3/1/2009#)
[/code]

The date format is mm/dd/yyyy

now i need to dynamically change the date froma different format "date=2009-02-01" (yyyy-mm-dd)

by

[code/]
xxday = Right(Right(Range("b2").Value, 10), 2)
xxMonth = Mid(Right(Range("b2").Value, 10), 6, 2)
xxYear = Left(Right(Range("b2").Value, 10), 4)

date = (xxMonth & "/" & xxday & "/" & xxYear)[/code]

The # in the first bit of code has me stumped - how do I set up the code to run the macro such as

datetoextract = (#date#) ????

 




Hi,

A DATE is a DATE, no matter the format.

Do you wnat a STRING rather than a DATE? BTW Date is a reserve word...
Code:
datetoextract = (#3/1/2009#)
dateSTRING =  Format(datetoextract, "yyyy-mm-dd")
But keep in mind that dateSTRING is ONLY TEXT and not a REAL DATE.

What are you using this result for?


Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
What about the IsDate and CDate (or DateValue) functions ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top