I am a newbie Talend developer, need a help with context variables. I searched here if there is a solution for similar approach, didnt find it.
In my query I have to use this date range function:
Date BETWEEN to_char((add_months(TRUNC(SYSDATE,'MM'),-2)),'YYYYMMDD')
AND to_char(LAST_DAY(TRUNC(SYSDATE,'MM')),'YYYYMMDD')
We need to use context variable to take advantage to run different date range during runtime. Above function, I replaced in the query with (date between ="+context.daterange+") and trying to plug these functions to Context - value as tree as below:
to_char((add_months(TRUNC(SYSDATE,'MM'),-5)),'YYYYMMDD')'AND'to_char(LAST_DAY(TRUNC(SYSDATE,'MM')),'YYYYMMDD'), I get below error:
java.sql.SQLException: ORA-00905: missing keyword
If I use hard coded value on "Value as tree" context as below then works
"'20150301'and'20150831'"
Trying to replace this with the function. How can I combine that function with AND.
My tJavacode has
context.DATE = (String)row1.NDate;
Can you please help?
Thanks
Date cannot be between two texts. Since your context variables is a String then use to_date function:
"select ... where my_date between to_date("
+TalendDate.formatDate("ddMMyyyy",TalendDate.addDate(new Date(), 2, "MM"))+
",'DDMMYYYY') and
+TalendDate.formatDate("ddMMyyyy",TalendDate.addDate(new Date(), 5, "MM"))+
");"
Related
I'm trying to seed my database, and one of my model's attributes is of type Date Array(timestamp with time zone). I end up getting this error:
column "myDate" is of type timestamp with time zone[] but expression is of type text[]
It works fine with a date type, but for some reason, only the Date Array is being interpreted as a text array.
I'm seeding the "myDate" field with something like this:
myDate: [new Date(), new Date()]
Am I missing something?
Here's what worked for me:
myDate: Sequelize.literal(`ARRAY['2004-10-19 10:23:54+02']::timestamp with time zone[]`)
Which is a slight variation on this issue:
https://github.com/sequelize/sequelize/issues/11541
(note the differenece in syntax between my answer and the one in the github issue. The latter didn't work for me.)
Or a more simpler form
myDate: '{2004-10-19 10:23:54+02}'
please note the curly brases are inside the quotes.
you could add even more values ex.
myDate: '{2004-10-19 10:23:54+02, 2010-13-19 10:23:54+02}'
Hope this helps.
Is there any expression from which I can directly get the month name in expression builder?
I am supposed to add month name with file name dynamically. I am currently using "DATEPART" function from which i recieved the month number but I want Month name. Can anyone help me?
No - unfortunately not. You have two options:
Return the month name from SQL as part of your dataset or
Do a bit of a crazy expression:
(MONTH(yourDate) == 1 ? "January" : MONTH(yourDate) == 2 ? "February" : MONTH(yourDate) == 3 ? "March" : etc etc)
SSIS Expressions have a very limited set of functions. If I remember correctly, it offers the functions that were available with VBScript way back when. There are no string formatting functions even in 2016 according to the documentation and people end up concatenating the various parts of a string.
You can use a Script step though to format a date using String.Format and store the result in a variable, as shown in [Using Variables in a Script Task] (https://msdn.microsoft.com/en-us/library/ms135941.aspx) and this SO question, eg:
var targetFolder=Dts.Variables["User::targetFolder"].Value;
var filePrefix=Dts.Variables["User::filePrefix"].Value;
var someDate=Dts.Variables["User::myDate"].Value;
var filePath= = String.Format(CultureInfo.InvariantCulture,"{0}_{1:MMMM}.txt",filePrefix,someDate);
var fullPath=Path.Combine(targetFolder,filePath);
Dts.Variables["User::filePath"].Value=fullPath;
The advantage of a script task is that you can use all of .NET's functions to format values (eg String.Format) and manipulate paths (eg Path.Combine, Path.GetFileNameWithoutExtension etc)
Hi Im using firefox and CoffeeScript in an app, I want to get current date with momentjs using default method moment() however when I debug the code I seeinvalid Date, it is very weird, this is my code:
questionStarts =
started_at: moment()
running: true
Then later in my code I create another object and add the property
answer = {}
answer.started_at = questionStarts.started_at
But when I check answer.started_at I get back Invalid date any idea?
Moment has an alternate constructor for strange dates. Since I can't see the value of answer.started_at in your code, I can only guess about how to solve your problem.
Consider for example some strange date format like 08.16.2015 00:00:00. Trying to construct a moment object from it will give the same error you have, Invalid date. That's what happens if you tried constructing my example like this:
//this doesn't work, throws Invalid date message
var ex = moment('08.16.2015 00:00:00');
So, to fix my problem, I give another constructor that informs Moment of the strange date format.
//this does work, however
var ex = moment('08.16.2015 00:00:00', 'MM.DD.YYYY hh:mm:ss');
Now, I can use ex as a typical moment object taking advantage of moment's other methods such as format() diff() and isBetween().
I am trying to calculate Month Name based on the Datepart calculation in SSRS.This code is working but with a warning..
=Switch(DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=12,"December",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=11,"November",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=10,"October",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=9,"September",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=8,"August",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=7,"July",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=6,"June",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=5,"May",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=4,"April",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=3,"March",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=2,"February",
DATEPART(DateInterval.Month,Fields!TRANSACTION_DATE.Value)=1,"January")
Warning :
[rsRuntimeErrorInExpression] The Value expression for the field ‘MONTH_NAME’ contains an error: Argument 'VarExpr' is not a valid value.
Please suggest how to remove this error.
Based on your expression, you should be able to use a much simpler expression with different date functions:
=MonthName(Month(Fields!TRANSACTION_DATE.Value))
When querying for relationships on a java.util.Date property, what syntax should I use? I tried just using a query like (this is just an example to show what I'm trying to do, so please don't pay attention to variable names there):
#Query("start n1=node({0}) match n1-[r:TYPE]->n2 where r.dateCreated>={1} return r")
Page<Relationship> findAll(Node node, long date, Pageable pager);
But it throws the following error:
Caused by: Don't know how to compare that. Left: 1339845862883; Right: 1339827156836
at org.neo4j.cypher.internal.Comparer$class.compareValuesOfDifferentTypes(Comparer.scala:45)
at org.neo4j.cypher.internal.Comparer$class.compare(Comparer.scala:67)
at org.neo4j.cypher.commands.ComparablePredicate.compare(ComparablePredicate.scala:30)
at org.neo4j.cypher.commands.ComparablePredicate.isMatch(ComparablePredicate.scala:41)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher$$anonfun$isMatchSoFar$1.apply(PatternMatcher.scala:148)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher$$anonfun$isMatchSoFar$1.apply(PatternMatcher.scala:148)
I also tried by passing a Date but it just throws the same error but trying to compare a Long and a Date.
I am using spring-data-neo4j version 2.0.1.RELEASE
So the date property's long value is stored as a string in the graph (in newer versions of SDN you can define a #GraphProperty(targetType=long.class) on date fields.
So comparison will work if you pass in the parameter value as String.valueOf(longValue)