Page 1 of 1
Modify date
Posted: Wed May 08, 2019 6:36 am
by AlessioForconi
Hello
I'm back to you with a question of mine, simple for everyone but hard for me
I have this data which I retrieve from a database
Code: Select all
put revDataFromQuery(, , conn, sqlGodute) into myArray
which contains this
21 2018-12-23 7 Ferie
22 2018-12-22 8 ROL
24 2019-03-27 1 ROL
30 2019-04-29 4 Banca Ore
my goal is to extract all the dates to modify them before showing them in a datagrid.
To do this, go write this
Code: Select all
set the itemDel to tab
repeat with x = 1 to the number of lines of myArray
answer item 2 of line x of myArray
put item 2 of line x of myArray into miadata
convert miadata to short date
answer miadata
end repeat
the problem is that miadata does not change, it remains the same even after convert.
No convert format works
What the hell am I wrong?
Re: Modify date
Posted: Wed May 08, 2019 7:48 am
by bogs
Hi Alessio,
Maybe
this lesson will help you understand the conversion a bit better.
The date and the short date are identical, by the way.
Dictionary wrote:
The date form returns the month number, the day of the month, and the last two digits of the year, separated by slashes (/).
The short date form returns the same value as the date form.
If you need those 3 digits in a specific order, you could set the itemDelimiter to "-" and arrange the items however you need it.
Re: Modify date
Posted: Wed May 08, 2019 9:33 am
by Klaus
Buongiorno Alessio,
and do not confuse yourself:
put revDataFromQuery(, , conn, sqlGodute) into myArray
revdatafromquery() does NOT return an ARRAY, but a CR and TAB delimited simple list of text!
Best
Klaus
Re: Modify date
Posted: Wed May 08, 2019 10:32 am
by richmond62
Iff you want to convert your dates to this format: Day-Month-Year I suppose you could do this:
Code: Select all
set the itemDel to tab
repeat with x = 1 to the number of lines of myArray
answer item 2 of line x of myArray
put item 2 of line x of myArray into miadata
set the itemDel to "-"
put item 1 of miadata into ANNUS
put item 2 of miadata into MENSIS
put item 3 of miadata into DIES
put DIES & "-" & MENSUS & "-" & ANNUS into miadata
answer miadata
set the itemDel to tab
end repeat
NOT rocket science, just a thought over a cup of coffee at lunchtime.

Re: Modify date
Posted: Thu May 09, 2019 7:02 am
by AlessioForconi
Klaus wrote: ↑Wed May 08, 2019 9:33 am
Buongiorno Alessio,
and do not confuse yourself:
put revDataFromQuery(, , conn, sqlGodute) into myArray
revdatafromquery() does NOT return an ARRAY, but a CR and TAB delimited simple list of text!
Best
Klaus
Yes Klaus. I took an example on how to extract the data from the database with the query, myArray was written and I, with guilty laziness, didn't verify that it was really an array. Until today.

Re: Modify date
Posted: Thu May 09, 2019 7:03 am
by AlessioForconi
bogs wrote: ↑Wed May 08, 2019 7:48 am
Hi Alessio,
Maybe
this lesson will help you understand the conversion a bit better.
The date and the short date are identical, by the way.
Dictionary wrote:
The date form returns the month number, the day of the month, and the last two digits of the year, separated by slashes (/).
The short date form returns the same value as the date form.
If you need those 3 digits in a specific order, you could set the itemDelimiter to "-" and arrange the items however you need it.
Thank you. It's really useful.
Re: Modify date
Posted: Thu May 09, 2019 7:05 am
by AlessioForconi
richmond62 wrote: ↑Wed May 08, 2019 10:32 am
Iff you want to convert your dates to this format: Day-Month-Year I suppose you could do this:
Code: Select all
set the itemDel to tab
repeat with x = 1 to the number of lines of myArray
answer item 2 of line x of myArray
put item 2 of line x of myArray into miadata
set the itemDel to "-"
put item 1 of miadata into ANNUS
put item 2 of miadata into MENSIS
put item 3 of miadata into DIES
put DIES & "-" & MENSUS & "-" & ANNUS into miadata
answer miadata
set the itemDel to tab
end repeat
Yes. I arrived at the same concusion following the bogs suggestion.
richmond62 wrote: ↑Wed May 08, 2019 10:32 am
NOT rocket science, just a thought over a cup of coffee at lunchtime.
Never underestimate the power of a cup of coffee
