|
Home > Archive > MS Access data conversion > July 2005 > How to convert data/time to string in query?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to convert data/time to string in query?
|
|
| Frank Xia 2005-07-27, 8:25 pm |
| How to convert date/time to string in query? So I can handle it with using
"Left" or "Right" function.
Thanks for any help in advance!
| |
| Brendan Reynolds 2005-07-27, 8:25 pm |
| You can do that with the Format function. However, if your purpose is to
extract a part of the date, you can do that in a more locale-independent way
using the various functions designed for that purpose, such as Year(),
Month(), Day(), etc.
Here's an example that on my system (where short date format includes
four-digit years) returns the same value in both columns (albeit one is a
string and the other is an integer). The first column might return a
different result on another system, the second column would not ...
SELECT Right$(Format$([OrderDate],"Short Date"),4) AS StringDate,
Year([OrderDate]) AS OrderYear
FROM dbo_Orders;
--
Brendan Reynolds (MVP)
"Frank Xia" < FrankXia@discussions
.microsoft.com> wrote in message
news:E224A9CD-0DA7-44B4-9D44- 286031B0F858@microso
ft.com...
> How to convert date/time to string in query? So I can handle it with using
> "Left" or "Right" function.
>
> Thanks for any help in advance!
| |
| Frank Xia 2005-07-28, 11:36 am |
| Thanks for your help. That is what I need.
"Brendan Reynolds" wrote:
> You can do that with the Format function. However, if your purpose is to
> extract a part of the date, you can do that in a more locale-independent way
> using the various functions designed for that purpose, such as Year(),
> Month(), Day(), etc.
>
> Here's an example that on my system (where short date format includes
> four-digit years) returns the same value in both columns (albeit one is a
> string and the other is an integer). The first column might return a
> different result on another system, the second column would not ...
>
> SELECT Right$(Format$([OrderDate],"Short Date"),4) AS StringDate,
> Year([OrderDate]) AS OrderYear
> FROM dbo_Orders;
>
> --
> Brendan Reynolds (MVP)
>
> "Frank Xia" < FrankXia@discussions
.microsoft.com> wrote in message
> news:E224A9CD-0DA7-44B4-9D44- 286031B0F858@microso
ft.com...
>
>
>
|
|
|
|
|