SQLite android - Select records within the last year - android-sqlite

i'm getting the sum() of the records of one month in this year.. here it is the method to get the month , but how can i get only the month of this year and not from the last year?
public Cursor calculate(String month){
return db.rawQuery("Select " + "sum(" + CN_GA + ")" +
" from " + TABLE_NAME + " where strftime('%m', " + CN_DATE + ") = '" + month +"'", null);
}
Note: mi date is in "yyyy-MM-dd HH:mm:ss" format.
thx for the answer in advance , and sorry for my english.

Combine with the condition
where strftime('%Y', yourdate) = "2015"
That is
" where strftime('%Y:%m', " + CN_DATE + ") = "
+ "'" + year + ":" + month + "'"

Related

Calculate sum if year and weekdate match in the columns

Good afternoon!
I am trying to write a sumifs function that will add up the "Total Gross Income" with the corresponding year and week number
Example
Week Number = 21 && Year = 2021 --> $602.85 ($68.75 + $117.60 + $285.00 + $131.50)
Week Number = 21 && Year = 2022 --> $47.42 ($7.75 + $6.25 + $17.06 + $16.30)
I tried to run this function:
=arrayformula(if(C2="","",sumifs($D$2:$D$9,$C$2:$C$9,C2:C)))
But, it will only return the total sum for the year 2021
Here is a link to a copy of the sheet: https://docs.google.com/spreadsheets/d/1eZbSQD6WxpFyaNw58htAT-d12kHZgIRIFofbdHtN9Ic/edit?usp=sharing
use:
=INDEX(IFNA(VLOOKUP(B2:B&C2:C, QUERY({B2:B&C2:C, D2:D},
"select Col1,sum(Col2) group by Col1 label sum(Col2)''"), 2, )))

Expression in SSIS returning date that does not exist

I have an expression that returns the date 6 months ago in the format 03/31/2021. This has been functioning as desired until today when it returned the date 09/31/2020, which does not exist. How can write the expression to get the desired results?
RIGHT("0" + (DT_WSTR,2)MONTH( DATEADD( "MONTH" , -6,GETDATE())), 2) +
"/"+ RIGHT("0" + (DT_WSTR,2)DAY(GETDATE()), 2) +
"/" +(DT_WSTR,4)YEAR(DATEADD( "MONTH" , -6,GETDATE()))
The problem is the second set of string logic
RIGHT("0" + (DT_WSTR,2)DAY(GETDATE()), 2)
It is getting the day number of current day (31). You likely intended to back that off 6 months as you do with Year and Month.
RIGHT("0" + (DT_WSTR,2)DAY(DATEADD("MONTH" , -6,GETDATE()), 2)
Were it me, I would create a new variable, AnchorDate and set Evaluate as Expression to True and use the expression
DATEADD("MONTH", -6, GETDATE())
I can test that, yes it's 6 months ago.
Now my date string becomes cleaner as I am not repeating (or not in 1/3 of your case) the date manipulation logic.
RIGHT("0" + (DT_WSTR,2)MONTH(#[User::AnchorDate]), 2) +
"/" + RIGHT("0" + (DT_WSTR,2)DAY (#[User::AnchorDate]), 2) +
"/" +(DT_WSTR,4)YEAR(#[User::AnchorDate])

AEM 6.2 JCR query on node property instead of JCR creation/modifiy/publish date?

I am trying to write a query where I can get content from a location in AEM dated from today's day back 24 months, but the date is not based on the publish/modify/creation date. They are asking for the dates to be based on the content called the "publish release date".
I have the following working off the creation date:
String sqlstmt = "SELECT * "
+ "FROM [nt:unstructured] AS comp "
+ "WHERE ISDESCENDANTNODE(comp, '" + pathLocation + "') "
+ " AND [sling:resourceType] = 'nvenergy/components/content/pressrelease' "
+ " AND comp.[jcr:created] >= "
+ " CAST('" + julianEndDateString + "T00:00:00.000Z' AS DATE) "
+ " AND comp.[jcr:created] < "
+ " CAST('" + julianCurrentDateString + "T00:00:00.000Z' AS DATE) "
+ " ORDER BY 1 ASC";
but I really need it to be off the content's "publish release date" found here:
...
if (currentNode.hasProperty("pressreleasepublishdate")) {
Calendar publishedDate =
currentNode.getProperty("pressreleasepublishdate").getDate();
...
Can I do a join or used something to use the node's property for the release date instead of the [jcr:created] as my range? Or do I have to execute the query hold it in a temp list and resort based on the node's property for the release date?

Tsql convert/cast full string without blank or delimiter to date time

I have a query log table (system table), it returns:
After attach the date and time, I need convert:
'20160404105625'
To dateTime type:
2016-04-04 10:56:25.00
You'll need the string in the format "20160404 10:56:25" to be able to convert it to the desired result:
SELECT CONVERT(DATETIME, run_date + ' ' + LEFT(run_time, 2) + ':' + SUBSTRING(run_time, 2, 2) + ':' + RIGHT(2, run_time))
FROM your_table

Cassandra wrong save time value

i'm done created code in express.js for save data into postgres and cassandra, code include for get time from server :
var currentdate = new Date();
var datetime = currentdate.getFullYear() + "-"
+ (currentdate.getMonth()+1) + "-"
+ currentdate.getDate() + " "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() + ":"
+ currentdate.getSeconds();
i use variable datetime for save data into postgres and cassandra, in postgres data datetime is 2015-09-17 09:39:27 but in cassandra is 2015-09-17 02:39:27+0000 there is different in time value
time in postgres is correct
how can i fix this ?
thx