Converting to time?

tiagofrancistiagofrancis Member Posts: 48
Hi folks..

I'm having some issues converting some data to time.

I need to convert two fields of my table to time, fieldHour and fieldMinute.
Both are integer. How can i convert them to time? =;


Thanks in advance.

Answers

  • kinekine Member Posts: 12,562
    You can try something like:
     EVALUATE(MyTime,FORMAT(fieldHour,0)+':'+FORMAT(fieldMinute,0));
    

    It means creating string from your values and convert this string into Time datatype... ;-)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • jreynoldsjreynolds Member Posts: 175
    Convert your hours and minutes to milliseconds since midnight and add to midnight.
    000000T + ((Hour * 60) + Minute) * 60000)
    
  • krikikriki Member, Moderator Posts: 9,110
    jreynolds wrote:
    Convert your hours and minutes to milliseconds since midnight and add to midnight.
    000000T + ((Hour * 60) + Minute) * 60000)
    
    This is better, because it is possible the divider between HH and MM and SS is not ":" but ".". I have to admit I don't know if Navision would accept it or not.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.