token expression in flat file connection - variables

I have loaded the variables in the format for example:
where produkt = 'Muj zivot2 R' and uraz = 'Uraz'
and I need the output in the file name to be:
Muj zivot2 R_Uraz
token worked for me, but it doesn't work in this case
" + TOKEN(" #[User::where] ","''",2) + "_" + TOKEN(" #[User::where] ","''",4) + "

You can use the following expression:
TOKEN(#[User::where],"'",2) + "_" + TOKEN(#[User::where],"'",4)
Output
Muj zivot2 R_Uraz

Related

System.IO.IOException: 'Bad file name or number'

I have this string and I am trying to write it with FileSystem.Write and I keep getting this error of 'Bad file name or number'.
sline = FormName + "|" + OrderNo + "|" + BatchNo + "|" + OpusOverlay + "|"
+ Overlay + "|" + Type + "|" + Numbered + "|" + NeedPDF +
Constants.vbCrLf;
FileSystem.Write(1, sline);
What could be the cause of this? Any push in the right direction would be greatly appreciated
An example of what Hans was referring
Using strw As StreamWriter = New StreamWriter(Path+file.ext)
strw.Write(sline)
End Using

Dynamic dates in where parameter

Am I able to use a dynamic date range for the "where" parameter? I'd like to get all the data changed in the last 30 mins.
All I can find in the documentation is using static dates:
https://developer.xero.com/documentation/api/requests-and-responses
You could try using the query string in the Where Clause.
For Ex.
string querystr = "Date >= " +
"DateTime(" + dateFrom.Year.ToString() + ",
" + dateFrom.Month.ToString() + ", " + dateFrom.Day.ToString() + ") " +
"&& Date <= " +
"DateTime(" + dateTo.Year.ToString() + ", "
+ dateTo.Month.ToString() + ", " + dateTo.Day.ToString() + ")";
Passing this querystring to retrieve user defined date rage Invoices

How do I get the current date in GML?

I need to be able to get the current date, it doesn't really matter what format it is. Is there a function, or perhaps an API i can use?
You can get the current date a number of ways in GML. The easiest of which is probably using the variables current_second, current_minute, current_hour, current_day, current_weekday, current_month, current_year
Here's an example that draws the day, month, and year.
draw_text(32, 32, "Today is " + string(current_day) + "/" + string (current_month) + "/" + string(current_year) +".");
You can change the timezone using date_set_timezone(timezone);
The available timezones are timezone_utc and timezone_local.
Another way to get the date is using date_current_datetime();
myhour = date_get_hour(date_current_datetime());
myday = date_get_day(date_current_datetime());
It exists some ways to do it. If you only need to show the current datetime you can use this:
show_message("Today is " + string(current_day) + "/" + string (current_month) + "/" + string(current_year) + " - " + string(current_hour) + ":" + string(current_minute) + "." + string(current_second) +".");
This will return something like: "Today is 3/6/2017 - 23:40:15."

Web2Py insert into database error

I am trying to make insert. This is my code:
db.define_table('orders',
Field('idProduct', type = 'integer'),
Field('quantity', type = 'integer'),
Field('idUser', type = 'integer'),
Field('status'),
Field('order_date'),
Field('product_price', type = 'integer'))
The SQL:
sql = "Insert into orders (idProduct,idUser,quantity,status,order_date,product_price) values "
sql = sql + "(" + str(idProduct) + "," + str(idUser) + "," + str(quantity) + ",'cart','" + str(order_date)+ "," + str(product_price)+"')"
and I am getting following error:
<class 'sqlite3.OperationalError'> 5 values for 6 columns
I don't understand what is wrong, because if i remove product_price, everything is working.
Thanks.
You have extra quote before the last closing bracket. Remove it and it will fix the error:
sql = sql + "(" + str(idProduct) + "," + str(idUser) + "," +
str(quantity) + ",'cart','" + str(order_date)+ "," +
str(product_price)+")"

SQL to_date function

im modifying an oracle table using the following line of code:
db.execute("INSERT INTO "+dbOwner+"tbl_name VALUES('" + id+ "','" + studID+ "','"+"TO_DATE('"+ dateStr +"','MM/DD/YY)");
dateStr value: 2014-04-25
var now = new Date(),
dateStr = now.getFullYear() + "-",
monthCode = now.getMonth() + 1;
dateStr += ((monthCode < 10) ? ("0" + monthCode) : ("" + monthCode));
dateStr += "-" + ((now.getDate() < 10) ? ("0" + now.getDate()) : ("" + now.getDate()));
use bind variables. your insert statement will be 'visible'. there would be no problem to add quotes for variables (it will be automatic). and bonus: it is safer and faster.
Also, you can pass date as date, without transformation to/from string.
It will not work only for schema name (dbOwner).
according to what you write in the question
dateStr value is: 2014-04-25
so you should modify the date format in your code to be:
yyyy-MM-DD