The constant is designed to be used in the Format() function.
If you use:
Format([MyDateField], "mm/dd/yyyy")
in a country where the Regional Settings (in Windows Control Panel) defines
the date separator is a dot, you actually get:
01.01.2006
i.e. the Format() function substitutes the local date separator for the
slash. To stop it doing that you need to specify that the next character is
a literal. Backslash is the prefix for that. So, the string
mm\/dd\/yyyy
tells the Format() function to use:
2-digit month, plus literal slash, plus 2-digit day, plus literal slash,
plus 4-digit year.
The date delimiter is the # character, so you could code:
"#" & Format([MyDateField], "mm\/dd\/yyyy") & "#"
Or you could get the same result by adding the literal # to the start and
end of the format string.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Rik said:
Public Const strcJetDate = "\#mm\/dd\/yyyy\#"
Hello,
I don't understand the backslashes \ in the above line.
I know it works in this way, but i also want to understand it.