format function date issue when region New Zealand and time format a.m.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
When retrieving rows from an SQL Server table I use the following code
select mydate, Customer, Details from sales where mydatetime >= " & format(somedate, "MMM d, yyyy h:mm:ss tt") & ""
This works fine unless the clients computers windows Region setting is English (New Zealand)
The default time format in windows Region and Language for New Zealand is
AM symbol = a.m.
PM symbol = p.m.
On computers with this region setting I get an SQL Error Conversion failed when converting date and/or time from character string
If I manually select the other option for AM symbol, PM symbol in Region and Language i.e AM PM the all works fine again
Question:<br/>
What format string can I use so that above code always works, even if the Region time format is a.m. / p.m.

regards
Steve


View the full article
 
Back
Top