how to convert time value to numeric value

For example: start=11:00:00am

end=12:00:00pm

result=01:00:00am

But actual result i want is 1 hour…

Any advise…[:)]

create timetaken as global variable with datatype Duration

then write timetaken := end-start;

calculation part is correct but i still must convert from timeOfDay to str right?

so how to covert that ,can you share the coding…

Can you explain clearly…

what do you need?

I do calculation method as per your sugget to me…

then the result come out is 01:00:00am, if the start date=11:00:00am and end date=12:00:00pm…

But the actual result i need is 1 hour (make it in string/real/numeric)…can you share the coding…

My idea is maybe i must to convert the result to string…but i not familiar with coding of converting…please advise…[:)]

can you show your code and datatypes of global variabls…

as I suggested above, I got 1 hour only as output…

This is my code, please correct if i’m wrong;

display timeOfDay TimeCount()
{
timeOfDay difftime;
difftime = this.endtime() - this.starttime();
return difftime;
}

so I guess you are working on AX and wrongly posted in NAV forum.

Hi Pizah,

I was developed one class for this type functionality

see document do want this class code reply me

G Chandrasekhar Ax Technical Consultant

DayHourTime

DayHourTime class developed for calculate the total days hours minutes seconds between start to end datetime

inputs StartDateTime and EndDateTime both are utcDateTime or StartTime and EndTime in the Seconds

outputs 2 days 23:30:20 or 71:30:20 called as method

Objects and Methods

str hours hours string in the formation hh

str minutes minutes string in the formation mm

str seconds seconds string in the formation ss

str hhMmSs formation hours,minutes and seconds hh,mm,ss

str hoursTime hourstime string inthe formation HH:MM:SS

str daysHoursTime daysHoursTime string inthe formation dd days HH:MM:SS

int quotient quotient int value for Dividend/Divisor

int totalTime totalTime int value for total seconds

int startTime startTime int value for start seconds

int endTime endTime int value for end seconds

int days days int value for total days

Methods

public int days(StartDateTime _startDateTime,

EndDateTime _endDateTime) returns a days int value defference between startdate and enddate

private int totalTime(StartDateTime _startDateTime,

EndDateTime _endDateTime) returns a totalseconds int defference between starttime and endtime

public int startTime(StartDateTime _startDateTime) returns starttime int value in the seconds

public int endTime(EndDateTime _endDateTime) returns endtime int value in the secounds

public str hours(int _time) returns hours string in the total seconds

public str minutes(int _time) returns minutes string in the total seconds

public str seconds(int _time) returns seconds string in the total seconds

private str hhMmSs(int _hhmmss) returns hhmmss string in the formation hh,mm,ss

public str hoursTime(int _days, Str _hours, Str _minutes, Str _seconds )

returns hoursTime string in the formation HH:MM:SS

public str daysHoursTime(int _days, Str _hours, Str _minutes, Str _seconds )

returns daysHoursTime string in the formation dd days HH:MM:SS

public str hoursTimeConsumed (StartDateTime _startDateTime,

EndDateTime _endDateTime) returns hoursTime string in theformation HH:MM:SS

public str daysHoursTimeConsumed (StartDateTime _startDateTime,

EndDateTime _endDateTime) returns daysHoursTime string in the formation dd days HH:MM:SS

public str timeConsumedHoursTime(int _startTime, int _endTime)

returns hoursTime string in theformation HH:MM:SS

public str timeConsumedDaysHoursTime(int _startTime, int _endTime)

returns daysHoursTime string in the formation dd days HH:MM:SS

If you want a result like “1 hour”, it’s actually not a time of day, it’s a duration (or a TimeSpan in .NET terminology). When you realize that AX time is number of seconds since midnight, you can easily write something like strFmt("%1 hours", time div 3600).

but asks time formats like HH:MM:SS

how to convert like that

@Sekharg: Look at X++ methods like time2str() or sime2StrHMS() or time2StrHMLeadingZero().

hi Martin,

it is correct

it’s good

thanks all

thanks

sekharg

Hi Martin its great reply.

Thanks

Rav