Get Time from DateTime

Vehlin

New Member
Hi there. I'm new to Progress and am having a little bit of an issue that the documentation isn't helping me with.

I have two DateTimes "dtStart" and "dtRateStartTime". The former contains both date and time and the latter contains just a time and some arbitrary date information (The SQL MinDate).

What I want to do is to get the time component from both variables so I can perform comparisons and arithmetic on them without having to worry about the actual dates.

I'm essentially trying to do the following, only in Progress.

Code:
if (dtStart.Hour >= dtRateStartTime.Hour)
{
    ...
}
 

anandknr

Member
Not sure if any inbult function to extract the hour from a datetime, but you can write a custom function to find that by parsing the datetime.The point that you shouldn't forget is that both DateTimes should be in same format .
 

Stefan

Well-Known Member
Not sure if the rounding is correct:

Code:
DEF VAR dt1 AS DATETIME.
DEF VAR dt2 AS DATETIME.


dt1 = NOW.
dt2 = DATETIME( 1/1/1752, 3600000 ).


MESSAGE
    dt1 SKIP
    dt2 SKIP(1)


    STRING( INTERVAL( dt1, ADD-INTERVAL( dt2, INTERVAL( dt1, dt2, "days":u ), "days":u ), "seconds":u ), "HH:MM:SS":u )
VIEW-AS ALERT-BOX.
 

Lechat

New Member
def var dtNow as datetime-tz.
def var dtNow0 as datetime-tz.

assign dtNow = Now
dtNow0 = date(dtNow).

// (dtNow - dtNow0 ) will give you time in milliseconds
disp dtNow dtNow0 (dtNow - dtNow0 ) .
 

SimonB

New Member
ou can also create a Class MyDateTime that contains a date, and hour(int), minutes (int) and so on.

You can also implements an "equals" method tout compare a MyDateTime with a .NET DateTime or a Progress Datetime.

With constructors that require System.DateTime or Datetime you can do almost anything.

Unfortunatly I can't share the code here.
 

andre42

Member
It seems that this thread was resurrected, but since nobody mentioned the MTIME function yet I thought I might just do that.
MTIME function
MTIME ( [datetime-expression] )
Returns an INTEGER value representing the time in milliseconds
 
Top