deepakb
21st October 2004, 10:02
Hi,
I am having problem in getting time in 24 hr fromat when i get date and time using utc.num() function. This function returns date and time in 12 hours format when used within function utc.to.date(). I tried comparing this utc value with utc value returned by function date.to.utc() when i gave input parameters in 24 hr format. In this case two utc values are different. Has anybody idea how to get time in 24 hour format?
malutz
21st October 2004, 10:07
Hej,
utc.num() delievers the time in seconds passed since (i guess) the 01-01-1900.
What excatly do you mean with the 24h format? Is that on a report, on a session? If yes, check the generic units (ttaad1106m000 and ttaad1107m000).
NPRao
21st October 2004, 10:51
Has anybody idea how to get time in 24 hour format?
You can use with sprintf$() -
%U(format)
Use for UTC times.
This option enables you to define your own time using the following subformats of the %U format.
%H hours in 24 hour format
Refer to the tools manual - sprintf$() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_formatting_io_sprintf)
deepakb
21st October 2004, 12:02
utc.num() returns current date and time in terms of secs (long) since 01-01-1970 00:00:00. I want to convert that long value using utc.to.date() to get exact year,month,day,hr,min,sec which is returning hrs in 12 hr format.
Even when i formatted UTC date n time using sprintf$() and format specifier %U and %H for 24 hr format then also the output string returns the time in 12 hrs format only. Do you have any idea of alternative for this?
NPRao
21st October 2004, 21:47
Deepak,
You should post your code for others to refer and suggest corrections.
Anyways here is the piece of code, you can execute in afternoon or set a time in afternoon.
string temp(256)
domain zmadm.utc utc.dt
utc.dt = utc.num()
temp = sprintf$(" %u(%02m/%02d/%04Y)-%U(%02H%x%02m%x%02s:%a) ", utc.dt, utc.dt)
deepakb
26th October 2004, 08:16
domain tcdate count.date
domain tcinvn ret
string time.prt(14)
count.date = utc.num()
ret = utc.to.date(count.date,year1,month1,day1,hour1,min1,sec1)
time.prt = sprintf$("%U(%02H%02m%02s)",count.date)
This is the code i have written.
i tried using sprinf$ also. But its not giving the fruitful result.
Kingsto88
17th November 2004, 09:53
Yes, I also tried the same but cannot get the correct result
sprintf$("%U(%02H%02m%02s)",utc.num())
the current time is 3:17 pm
Using the above, I get 091702
It should not be 09. It should be 15.
Why this wrong time? I am trying this on Baan5.
Regards
NPRao
17th November 2004, 20:43
This works for me -
count.date = utc.num()
ret = utc.to.date(count.date,year1,month1,day1,hour1,min1,sec1)
buffer = sprintf$(" %u(%02m/%02d/%04Y)-%U(%02H%x%02m%x%02s:%a) ", count.date, count.date)
buffer = sprintf$("Date - %u(%02m/%02d/%04Y) ", count.date)
buffer = sprintf$(" Time - %U(%02H%x%02m%x%02s:%a) ", count.date)
You have to check what is the time zone specifed for you in the user data template, which can affect your results.