h_hamed79
17th June 2014, 15:24
Hello All,

Are there any function in Infor like function dateadd in T-SQL which adding integer to specific part of date field as below

select dateadd(month,10,'2010-11-08 00:00:00.000') from ttpmwt001340

result: (2011-09-08 00:00:00.000)

another question are there a tool in Infor like management studio in sql to test the sql query results ?

Thanks in advance .

avin_ln
18th June 2014, 08:16
Hello,
You can test your SQL queries on LN
Step 1: Tools -> SQL Queries -> Query Data, in this session generate your SQL query
Step 2: Tools -> SQL Queries -> Execute Query, in this session find your query and execute it

bdittmar
18th June 2014, 09:47
Hello,

refer to LN-Progguide and use utc.add

utc.add()
Syntax:

function long utc.add (long i.utc, long year, long month, long day, long hour, long minute, long second, long o.utc)

Description


This adds years, months, days, hours, minutes, seconds to the input utc value and makes corrections if necessary.

It processes the parameters from bigger to smaller units:

First adds only years and the date is corrected (if started from a leap year)
Than the months are added and the date is corrected to an existing one.
The addition of days follow, and the result is so far the same hour, minutes, as it was in the beginning in the actual time-zone.
Finally the hours, minutes, seconds are added.

Regards

h_hamed79
18th June 2014, 10:08
Dear avin_ln

Thanks very much for your valuable instruction .

Regards,

h_hamed79
18th June 2014, 15:17
Dear bdittmar,

Thanks for your helpful reply , i will use this function but i still have an issue in (long i.utc) parameter , i will explain what i want to do exactly

i have field come from table which in type date , so i need to convert it first to utc to use it as i read that function date.to.utc() can be used but i don't know how in my case , i try to use it as in_utc = date.to.utc(phand.over.date) where phand.over.date is variable from type date but i have error from compiler state that ( Error: 6 arguments expected for function 'date.to.utc') , now the question is how to convert this variable (phand.over.date) to be in 6 arguments shape required .

I have copied below the function that i want to write
--------------------------------------
function domain tfgld.date display.final.handover.date (domain tccprj prj.prjno)
{
domain tfgld.date fhand.over.date ,phand.over.date
domain tppss.tmfc war.in.month
long in_utc,res,ou_utc
select tpmwt001.phod,tpmwt001.wppm
from tpmwt001
where tpmwt001.cprj = :prj.prjno
selectdo

phand.over.date = tpmwt001.phod
war.in.month = tpmwt001.wppm

in_utc = date.to.utc(phand.over.date)


res = utc.add( in_utc, 0, war.in.month, 0, 0, 0, 0, ou_utc )

long year, month, day, hours, minutes, seconds
fhand.over.date = utc.to.date (ou_utc, year, month, day, hours, minutes, seconds)


endselect
return (fhand.over.date)
--------------------------------------------------------

Thanks for you help.

Regards,

bhushanchanda
18th June 2014, 15:50
Hi,

Try this:-

string year(5), month(5), day(5)
long year.no,month.no,hours.no,minutes.no,seconds.no

day = sprintf$("%D(%02d)",phand.over.date )
month = sprintf$("%D(%02m)", phand.over.date)
year = sprintf$("%D(%04Y)", phand.over.date)

in_utc = date.to.utc (val(year), val(month),val(day),0,0,0)

utc.add( in_utc, 0, war.in.month, 0, 0, 0, 0, ou_utc )

utc.to.date (ou_utc, year.no, month.no, day.no, hours.no, minutes.no, seconds.no)

fhand.over.date = date.to.num(year.no,month.no,day.no)

h_hamed79
19th June 2014, 13:01
Hi Bhushan,

Thanks very much for you helpful reply :) , i used your code and it is working .

Regards,