?
Solved

Hour date in 1:00 AM format fro ms sql server 2005

Posted on 2011-03-04
6
Medium Priority
?
272 Views
Last Modified: 2012-05-11
How do I conver this:
DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())

to this:
1:00 AM
0
Comment
Question by:GlobaLevel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35038720

try using convert
select CONVERT(varchar,  @CURR_DATE, 108)
0
 
LVL 3

Expert Comment

by:AndrewSkoraro
ID: 35038732
CONVERT(@CURR_DATE , GETDATE() , 108)
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 35038774
is this right?

DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())

DECLARE @DAILY_CURR_DATE nvarchar(max)
SET @DAILY_CURR_DATE = select CONVERT(varchar,  @CURR_DATE, 108)
0
How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 35038806

Remove the select

DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())

DECLARE @DAILY_CURR_DATE nvarchar(max)
SET @DAILY_CURR_DATE = CONVERT(varchar,  @CURR_DATE, 108)
0
 
LVL 41

Accepted Solution

by:
Sharath earned 2000 total points
ID: 35039327
try this.
DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
 SELECT CASE WHEN DATEPART(HOUR,@CURR_DATE) BETWEEN 0 AND 11 THEN CAST(DATEPART(HOUR,@CURR_DATE) AS VARCHAR(2)) + ' AM'
            ELSE CAST(DATEPART(HOUR,@CURR_DATE)-12 AS VARCHAR(2)) + ' PM'
        END AS time_AMPM
-- 11 AM

Open in new window

0
 
LVL 41

Expert Comment

by:Sharath
ID: 35039348
You can try this if you are working in SQL Server 2008.
DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())
 select CONVERT(varchar,CONVERT(time,@CURR_DATE),100)
 -- 11:46AM
 

Open in new window

0

Featured Post

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question