ryanwee510
7th November 2008, 03:51
Hi, i have a problem with a program script

date A = 10-10-2008
date B = 30-10-2008

I want to convert the date A to date.to.num. then compare with a specific date B.

how i done it. please help me

Thanks.
Regards

george7a
7th November 2008, 09:33
Hi,

What is the problem?
Are you getting an error?
Can you post your script?

- George

bdittmar
7th November 2008, 10:14
Hi, i have a problem with a program script

date A = 10-10-2008
date B = 30-10-2008

I want to convert the date A to date.to.num. then compare with a specific date B.

how i done it. please help me

Thanks.
Regards

Hello,

BaanERP Programmers Guide


date.to.num()

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

Syntax
long date.to.num( long yearno, long monthno, long month_dayno )

Description
This returns the number of days since 01-01-0001 for a specified year, month, and day of the month.

Return values
0 The number of days since 01-01-0001.

-1 Error.


Context
Bshell function.

Example
long no_of_days
no_of_days = date.to.num( 1991, 04, 20 ) | Returns 726942


Regards

ryanwee510
11th November 2008, 01:59
The problem is I dun know how get input like 01-01-0001 from table then count into number of days.

bdittmar
11th November 2008, 14:13
The problem is I dun know how get input like 01-01-0001 from table then count into number of days.

Hello,

built variables like :

string str_day(2)
string str_month(2)
string str_year(4)

fill these strings like:

str_day = DateA(1;2)
str_month = DateA(4;2)
str_year = DateA(7;4)

convert these strings to longs with val / lval

lday = val(str_day) .......


then use adate = date.to.num(lyear, lmonth, lday)

The same with date B

datedifference = bdate - adate

Regards

mark_h
13th November 2008, 16:33
The problem is I dun know how get input like 01-01-0001 from table then count into number of days.

Are you reading from a table? How is the date declared? If a string field then use what bdittmar posted. If it is a date field then you can use simple math to get number of days:

domain tcdate today
today = date.num()
days = today - tisfc001.prdt

This would give me the number of days before or after the date. You might need to clarify your request. And then don't forget to search this forum for addition threads.

_Ralph_
13th November 2008, 17:28
Just for remember

UTC - number of seconds since January 1, 1970 00:00
Date- Number of days since 01-01-0001