Link to home
Create AccountLog in
Avatar of GlobaLevel
GlobaLevelFlag for United States of America

asked on

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

How do I conver this:
DECLARE @CURR_DATE smalldatetime
 SET  @CURR_DATE = ISNULL(@CURR_DATE, getDATE())

to this:
1:00 AM
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image


try using convert
select CONVERT(varchar,  @CURR_DATE, 108)
Avatar of AndrewSkoraro
AndrewSkoraro

CONVERT(@CURR_DATE , GETDATE() , 108)
Avatar of GlobaLevel

ASKER

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)

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)
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
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