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

Problem Formatting Date

Status
Not open for further replies.

rosieb

IS-IT--Management
Sep 12, 2002
4,279
GB
I'm comparing two dates and I know I'm getting a mismatch between UK and US date formats - it works fine after the 12th of the month!

I can't work out the syntax to force the format

Code:
varX = DLookup("[HolDate]", "PublicHolidays", "[HolDate] = #" & strDate1 & "#")

strDate1 is in "yyyy-mm-dd" format.

I've tried everything I can think of to format HolDate similarly, but I'm missing something.




Rosie
"Never express yourself more clearly than you think" (Niels Bohr)
 
Sorry, I don't know how to do the Code window like you did above, but here is what you can do:

varX = DLookup("[HolDate]", "PublicHolidays", "format([HolDate],"mm/dd/yyyy") = format(strDate1,"mm/dd/yyyy")"

Not sure if that is the specific format you want, but you can look in help to find the specific format.
 
hneal98

Thanks, but it doesn't work [sad], it gives a compile error "Expected: list separator or)" Which is what I seem to get whatever I try!

(The code window is just [ignore]
Code:
nnnn
[/ignore])


Rosie
"Never express yourself more clearly than you think" (Niels Bohr)
 
Thanks for the tip. I learned something from you.

Try changing the "" to '' inside of the main quotes. Like this:

Code:
varX = DLookup("[HolDate]", "PublicHolidays", "format([HolDate],'mm/dd/yyyy') = format(strDate1,'mm/dd/yyyy')"
 
Sorry, it should be like this:

Code:
varX = DLookup("[HolDate]", "PublicHolidays", "format([HolDate],'mm/dd/yyyy') = format(strDate1,'mm/dd/yyyy')")
 
Thanks again, but still the same error message.

Rosie
"Never express yourself more clearly than you think" (Niels Bohr)
 
Not sure what I've done here,I changed a few things and am now getting an automation object error with your code - clearly my fault.

However, I've solved the problem by formatting strDate1 to "mm/dd/yyyy" before performing the DLookup.

But thanks for your help and patience, I wouldn't have thought of using the mm/dd/yyyy format - I was so focussed on yyyy-mm-dd.

(I'll poke around this later and work out exactly what's been happening. At the moment I think I need food!)

Rosie
"Never express yourself more clearly than you think" (Niels Bohr)
 
Ok. Let us know if you have difficulty figuring that out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top