Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Distribution, Transportation & Warehousing

Retirement Notice

Baanboard is shutting down on 31-dec-2023. See: http://www.baanboard.com/baanboard/showthread.php?t=76043


User login

Frontpage Sponsor

Main

Poll
What do you expect from your SI Implementation partner for the success of ERP implementation.
Bring best practices - Not to offer more CR's Leveraging standard functions
20%
Need more honesty to work with the Users until their processes are fully mapped & Users are trained
40%
Focus on process automation/ integrations/ Real time data/ BI analytics
13%
Stick to basics
27%
Total votes: 15

Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 18th October 2011, 15:34
randeep randeep is offline
Newbie
 
Join Date: Oct 2011
Posts: 2
randeep is on a distinguished road
Baan: baanIV c4 - DB: sql server 3 - OS: windows 2000
Angry time conversion
Baan: Baan IVc4

Hi all,
I am a new user of baan Iv c4, i've working in distribution module, i wanted to read a time ( from table i.e tdsls050 ) e.g. 42629 into IST format or hr:mm:ss format . please help me out.
regards
randeep
Reply With Quote
  #2  
Old 18th October 2011, 16:39
bdittmar's Avatar
bdittmar bdittmar is offline
Guru
 
Join Date: Apr 2002
Posts: 1,982
bdittmar will become famous soon enough
Baan: 2.2/3.1/4c4/LN6.1 FP6/FP9/HiDox Tools 10.7/D.3 - DB: tbase, ms-sql7, oracle10gV1, 11g, 12c, 19c - OS: HP-UX, W2K3, SLES, RHLE
Seconds from 00:00

Hello,

time is stored as seconds since 00:00

So calculation could be done as 42629 : 3600 gives 11 hours a.s.o.

Or use sprintf$()

BaanERP Programmers Guide


sprintf$()

--------------------------------------------------------------------------------

Syntax
string sprintf$( string format(.) [, expression, ...] )

Description
This formats a string and returns the formatted string. The format argument contains zero or more ordinary characters and substitution symbols. The ordinary characters are copied directly to the output string. The substitution symbols specify formats for the values specified in the expression arguments and are substituted by these formatted values.

The substitution symbols are used in the sequence in which they are specified. The first substitution symbol is used for the first expression argument. The second substitution symbol is used for the second expression argument, and so on.

In addition to a range of numeric type expressions, the function supports dates, amounts, single-byte strings, multibyte strings, bidirectional strings, and combined normal and bidirectional strings. input strings that contain bidirectional strings must be specified in logic order. The result is also returned in logic order.

Substitution symbols
Substitution strings have the following syntax:

%[-][min][.max]type

The elements of a substitution string have the following meanings:

%
All substitution strings begin with a percentage character [%]. To output the percentage character itself, specify it as ‘%%’.

-
An optional flag indicating that the output string is to be left justified. If this is omitted, the output string is right justified by default.

min
Specifies the minimum length of the output field. If the output string has fewer characters than the minimum field width, it is filled out with spaces. By default, these are inserted at the start of the field. If the ‘-‘ flag is specified, the spaces are inserted at the end of the string.

Instead of an integer constant, you can specify the length with an asterisk[*]. In this case, the corresponding expression argument must supply the length.

max
Specifies either the maximum number of digits after the decimal sign (for ‘%e’ and ‘%f’ substitution types), the maximum number of digits (for ‘%g’ substitution types), or the maximum string length (for ‘%s’, ‘%A’, ‘%D’, ‘%u’, and ‘%U’ substitution types).

Instead of an integer constant, you can specify the length with an asterisk[*]. In this case, the corresponding expression argument must supply the length.

type
The type of conversion to be applied to the substituted value (see below).


The type element can have one of the following values:

%Axxx[,CUR]
Use for amounts.

xxx is the code for an amount format defined in the data dictionary. CUR indicates the currency code to use. It this is omitted, the default currency of the company of the user is used.

%Dxxx[,lang]
Use for dates.

xxx is the code for a date format defined in the data dictionary. lang indicates the language code to use. If this is omitted, the current user language is used.

The expression that is substituted for this symbol must specify a number of days since 01-01-0001.

%D(format)
Use for dates.

This option enables you to define your own date format by using the following subformats of the ‘%D’ format:

%m month in year 1 - 12
%w week in year 0 - 53
week 0 in previous year week 53 in current year

%W week in year 1 - 53
week 53 in previous year

%d day in month 1 - 31
%e day in week 1 - 7
%j day in year 1 - 365
%y year without century 01 - 99
%Y year with century 1 - 9999
%h name of month (‘Jan’ - ‘Dec’)
(abbreviated)
%H name of month (‘January’ - ‘December’)
%a name of day (‘Sun’ - ‘Sat’)
(abbreviated)
%A name of day (‘Sunday’ - ‘Saturday’)

You can combine these subformats with other formats. Note that strings returned by name of month and day formats are language dependent.

%uxxx
Use for UTC dates. xxx is the code for a UTC date format defined in the data dictionary.

%Uxxx
Use for UTC times. xxx is the code for a UTC time format defined in the data dictionary.

%u(format)
Use for UTC dates.

This option enables you to define your own date format by using the subformats described for the ‘%D(format)’ symbol. You can combine these subformats with other formats.

Note that strings returned by name of month and day formats are language dependent.

%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
%h hours in 12 hour format
%m minutes
%s seconds
%a substitutes the am/pm symbol as defined for the user language
%x time separator as specified for the user language

You can combine these subformats with other formats.

%d
Use for long values.

%e
Use for double values with exponent.

%f
Use for doubles values with 6 decimal places.

%g
Use for double values.

%s
Use for single-byte and multibyte strings.

%o
Use for octal representations of numbers.

%x
Use for hexadecimal representations of numbers.

%@format@
Use for formatting values by using the formatting characters described for edit$().


Return values
The formatted string. If you specify an invalid format, sprintf$() returns a percentage character [%].

Context
Bshell function.

Examples
Format
Value
Result

%f
1.2
"1.200000"

%10f
1.2
" 1.200000"

%10.2f
1.2
" 1.20"

%-10.2f
1.267
"1.27 "

%10.6g
1234.567
" 1234.57"

%10.2e
12.34
" 1.23e+01"

%-10.2e
12.34
"1.23e+01 "

%10d
1
" 1"

%10d
-1
" -1"

%-10d
1
"1 "

%-10d
-1
"-1 "

%10s
"12"
" 12"

%-10s
"12"
"12 "

%10s
"123456789012"
"123456789012"

%.10s
"123456789012"
"1234567890"

%@ZZVD99@
1.267
" 1.26"

Format
Result

%s
Returns the full string.

%20s
Right justifies the string in a field of 20 positions. If the string is longer 20 positions, the field is lengthened to accommodate the full string.

%-20s
Left justifies the string in a field of 20 positions. If the string is longer 20 positions, the field is lengthened to accommodate the full string.

%20.20s
Right justifies the string and limits its size to 20 positions. Partially displayable multibyte characters (2 characters wide) will be spaced out.


Strings

string result(80), word(20)

word = "word"

result = sprintf$("This is a '%*s' of 10 positions",10,word)

| result contains "This is a ' word' of 10 positions"

Doubles

string result(80)

result = sprintf$("number: %-*.*f",10,2,1.2")

| result contains "number: 1.20 "

| minimum length of the double value is 10 positions

| number of digits after decimal sign is 2

Amounts

| Suppose the default currency is USD ($)

| and A001 is defined as "$$ 999T999T999VD99"

string result(80)

result = sprintf$("%A001", 1234.56)

| result contains "$ 000,001,234.56"

result = sprintf$("%-10A001,hfl", 1234.56)

| result contains "fl 000.001.234,56"

result = sprintf$("%-.10A001,hfl", 1234.56)

| result contains "001.234,56"; there is insufficient space

| for currency symbol

Dates

| Suppose date format 002 is: "year/month/day in month"

string result(80)

result = sprintf$("%D002", 727168)

| result contains "1991/12/2"

| Example of substitution symbol %D(format)

string result(80)

result = sprintf$("%D(Date: %02d/%02m/%04Y)", date.num())

| result contains "Date: 12/07/1993"

result = sprintf$("Date: %D(%02d %-20H %04Y)", date.num())

| result contains "Date: 12 June 1993"

UTCdates and times

| Date format 002 is "year/month/day in month"

| Time format 001 is "12 hour format:minutes:seconds AM/PM symbol"

string result(80)

result = springf$(" %001", utc.num(), utc.num())

| Result contains "1997/01/01 10:02:53 pm"

string result(80)

result = sprintf$("UTC: %u(%02d/%02m/%04Y) %U(%02h%x%02m%x%025 %a)", utc.num(), utc.num())

| result contains "UTC: 22/07/1997 06:24:53 am"

| provided that for the user's language the time

| separator is ":" and the AM symbol is "am"



Regards
__________________
//Bernd

Last edited by bdittmar : 18th October 2011 at 16:44. Reason: add sprintf$()
Reply With Quote
  #3  
Old 29th November 2011, 09:15
rket4u rket4u is offline
Junior Member
 
Join Date: Nov 2011
Posts: 3
rket4u is on a distinguished road
Baan: SAS 9.1.3 - DB: OTM - OS: Windows XP
If you have a time in a decimal format, i.e. an integer and a fraction, e.g. 2.5 hours (2 and a half hours) and you want to convert to a standard time format 02:30 (2 hours and 30 minutes), then you can use a formula based on the TIME function with the following syntax:
TIME(hours,minutes,seconds)
Example:
We have a decimal time 2.5 in cell A2. we can use the following formula to convert it to a standard time:
=TIME(INT(A2);(A2-INT(A2))*60;0)
• The first parameter in this formula, hours is equal to the integer part of the decimal value: INT(A2).
• The second parameter, minutes is equal to the fraction of the decimal value multiplied by 60: (A2-INT(A2))*60.
• The last parameter seconds, is set to 0 in our example.
Reply With Quote
  #4  
Old 19th December 2011, 12:30
baanravi baanravi is offline
Senior Member
 
Join Date: May 2006
Posts: 107
baanravi is on a distinguished road
Baan: b4c4, ERP, LN - DB: Oracle, SQL - OS: Unix
include function

you may use include function tfgld0032 for this
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Default time is different from System Time bumbaermail Tools Administration & Installation 1 10th May 2011 10:26
Time Conversion... suhas-mahajan Tools Development 6 8th October 2004 07:41


All times are GMT +2. The time now is 00:53.


©2001-2023 - Baanboard.com - Baanforums.com