How do I display time from
23:00:00 to 11:00pm
or vice versa,
Thanks,
Lam"culam" <culam@.discussions.microsoft.com> wrote in message
news:39CB0644-279D-448A-9389-357871CEBDF1@.microsoft.com...
> How do I display time from
> 23:00:00 to 11:00pm
> or vice versa,
> Thanks,
> Lam
Do you mean how do you format the display of a DATETIME value? Your client
application controls how dates and times are displayed - not SQL Server.
Best to take a look at the features of whatever client you are using.
The only way to have any control over this with SQL Server is to return a
string instead of a DATETIME. That's a poor idea for several reasons but if
you really want to do it take a look at the CONVERT function in Books
Online.
David Portas
SQL Server MVP
--|||Since CONVERT() function return different format for Date, I thought one of
them might get me the desired time format. I tried but no prevail. There is
no Client side on my environment. I just get data from Query Analyzer and
present it to my boss.
Thanks,
Lam
"David Portas" wrote:
> "culam" <culam@.discussions.microsoft.com> wrote in message
> news:39CB0644-279D-448A-9389-357871CEBDF1@.microsoft.com...
> Do you mean how do you format the display of a DATETIME value? Your client
> application controls how dates and times are displayed - not SQL Server.
> Best to take a look at the features of whatever client you are using.
> The only way to have any control over this with SQL Server is to return a
> string instead of a DATETIME. That's a poor idea for several reasons but i
f
> you really want to do it take a look at the CONVERT function in Books
> Online.
> --
> David Portas
> SQL Server MVP
> --
>
>|||you could parse CONVERT results, e.g.
select substring(convert(varchar, getdate(), 100),13,7)
culam wrote:
> Since CONVERT() function return different format for Date, I thought one o
f
> them might get me the desired time format. I tried but no prevail. There
is
> no Client side on my environment. I just get data from Query Analyzer and
> present it to my boss.
> Thanks,
> Lam
> "David Portas" wrote:
>|||"culam" <culam@.discussions.microsoft.com> wrote in message
news:66069841-E6F0-44A3-85AB-D75711D8356C@.microsoft.com...
> Since CONVERT() function return different format for Date, I thought one
> of
> them might get me the desired time format. I tried but no prevail. There
> is
> no Client side on my environment. I just get data from Query Analyzer and
> present it to my boss.
> Thanks,
> Lam
> "David Portas" wrote:
>
CONVERT allows you to format dates as *strings*. DATETIME itself has no
specific formatting. For example:
SELECT CONVERT(VARCHAR(8),CURRENT_TIMESTAMP,14)
The result is a VARCHAR not a DATETIME.
Alternatively, in Query Analyzer select Tools / Options / Connections and
check the option that says "Use regional settings when displaying currency,
number, dates and times." to control how the dates are formatted. Query
Analyzer is a client application like any other but it's not a very good
tool for presentational work. You might be better off investing in a
reporting tool.
David Portas
SQL Server MVP
--
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment