Re: How to convert data/time to string in query?
- From: "Brendan Reynolds" <brenreyn@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 27 Jul 2005 23:37:59 +0100
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@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E224A9CD-0DA7-44B4-9D44-286031B0F858@xxxxxxxxxxxxxxxx
> 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!
.
- Follow-Ups:
- Re: How to convert data/time to string in query?
- From: Frank Xia
- Re: How to convert data/time to string in query?
- References:
- How to convert data/time to string in query?
- From: Frank Xia
- How to convert data/time to string in query?
- Prev by Date: How to convert data/time to string in query?
- Next by Date: Missing or broken reference to the file "VIDTC3.OCX"
- Previous by thread: How to convert data/time to string in query?
- Next by thread: Re: How to convert data/time to string in query?
- Index(es):
Relevant Pages
|