Convert text in Date

Posted by rogeliolt on 01-Jul-2015 19:28

Hi Community.

I'm using com-handle becouse I'm updating information into my table using a Excel file.

But I have a little problem, I don't know convert this value "2014-10-08" to date value.

I use this code:

cRango = "AD" + STRING(iren).
CHHOJA:RANGE(cRango):NumberFormat = "@".
chhoja:range(cRango):VALUE = string((chhoja:range(cRango):VALUE),"9999/99/99").

and this:

cRango = "AD" + STRING(iren).
CHHOJA:RANGE(cRango):NumberFormat = "date".
chhoja:range(cRango):VALUE = date(chhoja:range(cRango):VALUE).

Can you help me?.


All Replies

Posted by TheMadDBA on 01-Jul-2015 19:39

Looks like your OE SESSION:DATE-FORMAT doesn't match what you are getting back from Excel.

You can specify the NumberFormat to be "mm/dd/yyyy" (probably much easier) or you can change the SESSION:DATE-FORMAT to "ymd" before you run the DATE function (and switch it back after).

Posted by eugenel on 01-Jul-2015 20:02

In Excel (not tied to any database), if you have A1 = '2015-6-30, you can format it in B1 = TEXT(A1,"YYYY-MM-DD"), which will show 2015-06-30; C1 = DATEVALUE(B1), which you can format it to whatever date format you desire like 30-Jun-2015; and D1 = C1+1, which will show 1-Jul-2015.

Posted by rogeliolt on 02-Jul-2015 11:13

Hi my friends.

Tanks for your help.

I solved my problem using the SESSION:DATE-FORMAT was most easy.

My solution is this:


fec = CHHOJA:Range(obtencol(icol) + STRING(iren)):VALUE.

tempexcel.fechaact = fec.

where fec is an date variable.

tempexcel is a temp-table.

icol and iren are integer variable.

CHHOJA is a com-handle.

Thanks for our help TheMadDBA and  eugenel.

Posted by TheMadDBA on 02-Jul-2015 11:22

No problem :-)

Don't forget to set the DATE-FORMAT back to the original value after you are done. Otherwise you will run into other issues.

This thread is closed