Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

How to format time?

k0piko

Novice
Advanced Member
Messages
27
Reaction score
0
Points
26
Hi mga boss,


paano ko po kaya mafoformat ung result ng ganito: 00:00:00


Code:
SqlQuery = "SELECT DateDiff('n', d_Assigned,c_Date) AS Time_Diff FROM tbl_List WHERE List_ID=" & ListID & ""
                
                                                With rs
                                
                                                        .Open SqlQuery, conn
                            
                                                        
                                                End With
       
       
                                MsgBox (rs.Fields("Time_Diff").Value)

Yung d_Assigned and c_Date ay pareho pong Date/Time
Yung Time_Diff is naka Date/Time din po.

ganito po sana ang gusto ko na result:

Code:
d_Assign = 02/17/2015 07:30:00 PM
c_Date = 02/17/2015 08:00:00 PM
Time_Elapse = 00:30:00

Ang nkkuha po na result is 30 eh
 
Hi mga boss,


paano ko po kaya mafoformat ung result ng ganito: 00:00:00


Code:
SqlQuery = "SELECT DateDiff('n', d_Assigned,c_Date) AS Time_Diff FROM tbl_List WHERE List_ID=" & ListID & ""
                
                                                With rs
                                
                                                        .Open SqlQuery, conn
                            
                                                        
                                                End With
       
       
                                MsgBox (rs.Fields("Time_Diff").Value)

Yung d_Assigned and c_Date ay pareho pong Date/Time
Yung Time_Diff is naka Date/Time din po.

ganito po sana ang gusto ko na result:

Code:
d_Assign = 02/17/2015 07:30:00 PM
c_Date = 02/17/2015 08:00:00 PM
Time_Elapse = 00:30:00

Ang nkkuha po na result is 30 eh

Try mo gumamit ng timespan.
 
convert mo yong minute duration mo to hours and seconds,

result = [timediff result query]

hours = (int) result / 60
result = result mod 60
min = (int) result / 60
sec = result mod 60

Time_Elapse hours " : " min " : " sec
 
I've used timespan, pero negative ung nirreturn

Code:
string d_Assign,d_Complete;

d_Assign = Convert.ToDateTime(DataReader["Date_Assign"]).ToString("MM/dd/yyy hh:mm:ss tt");
d_Complete = Convert.ToDateTime(DataReader["Date_Completed"]).ToString("MM/dd/yyy hh:mm:ss tt");
System.TimeSpan diff2 = Convert.ToDateTime(d_Assign) - Convert.ToDateTime(d_Complete);

Example:
Code:
d_Assign = 02/17/2015 04:30:00 PM
d_Complete = 02/17/2015 04:35:00 PM
diff2 = -00:05:00

baket po kaya negative?
 
I've used timespan, pero negative ung nirreturn

Code:
string d_Assign,d_Complete;

d_Assign = Convert.ToDateTime(DataReader["Date_Assign"]).ToString("MM/dd/yyy hh:mm:ss tt");
d_Complete = Convert.ToDateTime(DataReader["Date_Completed"]).ToString("MM/dd/yyy hh:mm:ss tt");
System.TimeSpan diff2 = Convert.ToDateTime(d_Assign) - Convert.ToDateTime(d_Complete);

Example:
Code:
d_Assign = 02/17/2015 04:30:00 PM
d_Complete = 02/17/2015 04:35:00 PM
diff2 = -00:05:00

baket po kaya negative?

Try:
diff2 = Convert.ToDateTime(d_Complete) - Convert.ToDateTime(d_Assign)
 
Ano ba gamit mo pang query, sa MSSQL working to.

declare @d_Assign as datetime
declare @c_Date as datetime

set @d_Assign = '02/17/2015 07:30:00 PM'
set @c_Date = '02/17/2015 08:00:00 PM'

select CONVERT(VARCHAR(8), @c_Date - @d_Assign, 108)

result: 00:30:00
 
Code:
SELECT TIMEDIFF('2015-02-17 08:00:00', '2015-02-17 07:30:00') AS Time_Diff
 
okay na po mag boss. Nagkabaligtad lng ung date complete at date assign ko. Tama si sir tobeexiv.

Salamat mga kasymb!
 
Back
Top Bottom