November 3, 2009 at 3:18 pm
Hi I have time in my table like this
Time
16:20
i want to see like
time
4:20 pm
can anybody help me in this issue,thanks.
ani
November 3, 2009 at 3:21 pm
Actually, not quite enough information. How is the data actually stored in the table, is the column defined as a datetime data type?
November 3, 2009 at 5:48 pm
hi
Data type is decimal ,its time field and extracted from AS 400 systems.
November 3, 2009 at 6:37 pm
Okay, it is a decimal value, how is it stored? Please provide a sample of the data.
November 3, 2009 at 7:38 pm
it was stored in below format
14,23
15,59
12,12
13,45
what i wwant here
14,23 =2:23 PM
15,59=3:59 PM
tahnks
November 3, 2009 at 8:21 pm
anitha.cherukuri (11/3/2009)
it was stored in below format14,23
15,59
12,12
13,45
what i wwant here
14,23 =2:23 PM
15,59=3:59 PM
tahnks
Being in the US, I am assuming the comma (,) is just like the decimal point (.) here, correct?
November 3, 2009 at 8:27 pm
Here is the code I developed.
declare @time decimal(4,2);
set @time = 14.23;
select right(convert(varchar(20), dateadd(mi, (@time - floor(@time)) * 100, dateadd(hh, floor(@time), 0)), 100), 7)
November 3, 2009 at 11:21 pm
select right(convert(varchar(18),getdate(),100),7)
Is that right?
November 4, 2009 at 6:23 am
q123126 (11/3/2009)
select right(convert(varchar(18),getdate(),100),7)Is that right?
Works on my computer at home.
Edit: Except you need to change the varchar(18) to varchar(19) or varchar(20) as I originally posted. You could also add an ltrim to the whole thing to eliminate the leading space for single digit hours.
November 8, 2009 at 4:03 pm
Hi
There is no comma in between 13,40.
I typed for better understanding.
actual format is 1340 ,1220,1440 and data type is decimal.
anyway thanks for help,
it gives me idea....
November 8, 2009 at 8:02 pm
One now begs to ask... is it DECIMAL or INT? 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
November 8, 2009 at 9:42 pm
And if it is decimal, how is it declared?
November 10, 2009 at 1:10 am
Hope this will works for you!
November 10, 2009 at 7:23 am
suresh.theyyath (11/10/2009)
Heh... I wrote such a function earlier in my SQL career... it's a fun function to write because it creates a huge understanding of DATETIME datatypes, but don't expect any real performance out of it. It tends to be quite slow especially compared to straight-ahead inline code.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply