gcharles
2nd July 2002, 18:38
Hi,
I have put an initial value date() on a table field (domain tcdate).
When I insert a record in that table, I have an error message
'Invalid date'. It seems that BaaN doesn't take care of the initial value !! How can I do to insert an initial value in a field not present on a form ?
Thanks

mark_h
2nd July 2002, 19:11
I have never done this, but a quick check of the help said use date, not date(). So maybe that is the problem. Just a guess.

Mark

gcharles
2nd July 2002, 19:15
I tried date, date(), utc, utc(), dte.num(), ...
same thing ...
when I insert a record in GMT, it works correctly

trchandra
2nd July 2002, 19:24
Hi Charles,

I had the same situation where I have to insert a record with date field filled with current date from the program instead of form. I used utc.num(), it works fine for me. If you dont want current date, you can pass 0 (zero), it should work!

gcharles
2nd July 2002, 19:29
Did you put utc.num() in the initial value of the table field or in a program script ?

trchandra
2nd July 2002, 19:45
I dont know whether you can do it at table level, but you can do at form level. You can keep the field on the form and set initial value to 'Date' in the form level. This will get the current date into the field. If you dont want the user to enter it, make it display field. In my case I had it on the form and in the program script.

mark_h
2nd July 2002, 19:46
Was your date field mandatory on the table? I just tried it on one of my tables. I did not get an error, but I also did not get todays date as the default. It was empty. Sorry I was not able to help.

Also in table maintenance mode all of my date fields default to todays date when manually inserting a record. Never really paid a whole lot of attention to this.

Good Luck!

Mark

NPRao
2nd July 2002, 20:48
Hi Charles,

I guess you need to check your program logic. It works for most of us here...

I just checked on our system, where we have a table fields with tcdate domain . It is being used in the check.input and when.field.changes sections.


if zmadm100.stat = zmmig.stat.migrated.to.qa then
zmadm100.stat = zmmig.stat.prod.approved
zmadm100.prlg = logname$
zmadm100.prdt = utc.num()
endif
if zmadm100.stat = zmmig.stat.qa.approved then
zmadm100.stat = zmmig.stat.migrated.to.qa
zmadm100.mqlg = logname$
zmadm100.mqdt = utc.num()
endif
if zmadm100.stat = zmmig.stat.dev.approved then
zmadm100.stat = zmmig.stat.qa.approved
zmadm100.qalg = logname$
zmadm100.qadt = utc.num()
endif


Can you check the data type on the domain tcdate on your system - is it Date or UTC Date/Time ?

mark_h
2nd July 2002, 20:55
Hi NPR!

It looks like he was tryinig to do this with the initial data on the table field and not in the program script. I am currently working on some code to track a few dates and I tested what charles mentioned, but it did not do what he expected. I think the real question is -How do you default a date field using the initial value field on the maintain table fields session? This way you do not have to use any code in the program script for the date.


Mark

gcharles
3rd July 2002, 09:52
Hi everybody,
Mark is correct, I want to put an initial value at table field level (not in a program script).
Otherwise, I can create a DAL on that table but it doesn't seem to work ...

~Vamsi
3rd July 2002, 23:07
Here is a qptool query I wrote and ran on our system. See what it generates on yours and what is the effect of those initial values.


select ttadv422.cpac, ttadv422.cmod, ttadv422.flno, ttadv422.fdnm, ttadv422.iniv
from ttadv422
where ttadv422.cdom = "date"
and ttadv422.iniv <> ""
and ttadv422._compnr = 0


Also, did you do a "db.set.to.default" on the table?

Chandra
3rd July 2002, 23:08
Are you using the function db.set.to.default() in your script before inserting the record? This function sets the fields of a record in the program script (not in the database) to the default values defined in the data dictionary.

gcharles
4th July 2002, 12:13
Thanks for your help but I do not want to initialize the field value in a program script but in the table's field definition. I ask BGS and they 've opened a defect for this problem because it should work...

cherokee
13th August 2013, 16:51
Have the same problem... want to initialize field on table with current date and "date" as initial value doesn't work; when inserting, I use db.set.default(...) but my field is empty, no date at all.

I have tried, date.num(), date(), date and none makes a diffrence.

thanks in advance

mark_h
13th August 2013, 20:16
I have just learned to use the date funtion in the report script. When I read the help on the initial value field it does not give me the impression that a function like date() is supported. Don't know that for a fact.