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

How can I convert the server date to the English format...

Status
Not open for further replies.

martindavey

Programmer
Jan 2, 2000
122
GB
I am trying to access rows from an MS Access table<br>which is organised within dates.<br><br>I am using a query similar to the following:-<br><br>select * from myTable<br>where myDate &gt;= #FirstDate#<br>and&nbsp;&nbsp;&nbsp;myDate &lt;= #LastDate#<br><br>The trouble is, my data has dates in the standard<br>English format dd/mm/yy<br><br>But I guess the American based server has the format<br>mm/dd/yy<br><br>Is there some way I can ensure that the 'myDate'<br>variable is always in the English format?<br><br>NB. Converting my data to a Non-English format<br>&nbsp;&nbsp;&nbsp;&nbsp;is not an option.
 
I can think of three ways to do what you ask:<br><br>1. Format it with your SQL statement.<br>Not sure about the syntax for MS Access JET SQL (I use SQL Server).&nbsp;&nbsp;In SQL Server it's CONVERT (data_type[(length)], expression [, style]).&nbsp;&nbsp;To convert to US English, you would set the style to 101.&nbsp;&nbsp;A cursory check in MS Access didn't turn up with an equivalent statement although I'm pretty sure there's one there.<br><br><br>2. Format it with VBScript.<br>Use the FormatDateTime function to format it:<br>The syntax is FormatDateTime(Date[, NamedFormat]) where NamedFormat is an Enumerator constant (Int value 0 - 4).&nbsp;&nbsp;You probably want to use 1 or 2.<br><br>3. Parse the date parts yourself and put the pieces back together in the format you want. <p> Jeff Friestman<br><a href=mailto: > </a><br><a href= View my Brainbench transcript</a><br>Brainbench 'Most Valuable Professional' for ASP<br>
Brainbench 'Most Valuable Professional' for JavaScript<br>
 
Thanks for your speedy reply.<br><br>Parsing myDate before the query seems to be the most<br>adequate solution.<br><br>Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top