anandpr1989
16th March 2016, 16:01
Hi All,
I want to import date field from csv file to one table. I have created csv file with some string fields and for that I am using %s format in seq.gets function. But for date field what could be format I can use? Currently it is present in MM/DD/YYYY format in csv file.
Please let me know and thanks in advance.
Ajesh
16th March 2016, 20:17
Well, the format which you can use is given in the Session "Maintain Date Formats". Its in Application Configuration Module. You need to see which date format corresponds to MM/DD/YYYY format. If its present take that value, and if not then you need to create the format and do runtime for that specific format.
Next,I assume you have taken the date in a Program Script Variable after you operate your seq.gets command.
Suppose you have taken it in file.date variable and the date format corresponding to the date MM/DD/YYYY format is 015.
long date.value
dat.value = inputstr.to.date( file.date, "%D015" )
tdsls870.date = dat.value | Once its in numerical value you can assign it to the table field
The date format you need to look in the Baan standard Session.
shah_bs
16th March 2016, 21:58
Assuming that the CSV file is being created by you or a system you can control, my recommendation for the date format inside the CSV file would be to make it as yyyymmdd. This will save a lot of grief and irritation down the line because of the lost initial zero (when either DD or MM is the first value).
That being done, the field can be converted to BAAN Date as follows:
|* Date:
|* Input Format = yyyymmdd
|* 12345678
|* p.field.c is a character field big enough to hold the date from
|* the CSV file. Let us say it is now filled in somehow
p.field.c = get.the.date.from.csv()
if not isspace(p.field.c)
then
p.tmp.date.c =
date.to.num(lval(p.field.c(1;4)),
lval(p.field.c(5;2)),
lval(p.field.c(7;2)))
endif
Hope this helps.