The expired time of data and `keep` parameter in TDengine - sql

I'm using TDengine database 2.1.3.0. I create a table with keep as 10.
I found that the data inserted 10 days ago are still in the database.
What may be the cause?

There is another parameter called "days" with default value 10 in TDengine. TDengine stores data in one data file every 10 days, this data file will not be deleted until all the data in the data file expire.
For example:
one data file may have data from Mar 15 to Mar 25, on Mar 26th, the data of Mar 15 should be expired, but this data file also have data from Mar 16 to Mar 25, so this data file should not be deleted. The data of Mar 15 should be still in database

Related

select one month data from particular source type

We got hdfs data in - source_type/yyyymmdd/hr/xxx.parquet
How do we search in hue/impala if we need one month of data (say Aug 2022) from a particular source_type?
Thanks!

Convert string to date SSRS

I have issue converting parameter string to date.
I have list of data as:
Jul 28 2017 Call
Jan 8 2018 SMS
Apr 24 2018 Call
Jul 2 2018 E-Mail
Jul 13 2018 Call
Oct 1 2018 Call
Nov 27 2018 E-Mail
Dec 31 2018 Call
Jan 1 2019 SMS
Apr 1 2019 SMS
Jun 4 2019 SMS
I want them to be presented as eg. 06/04/2019 if possible
I tried LSet(Format(Parameters!DateInfo.Label,"MM/dd/yyyy"),12) in expression, but when I run the report it is showing me just like this MM/dd/YYYY.
For your parameter, you probably should be using a dataset for the dates with the Value set to use a date field and the Label using the string representation of the date (CONVERT(CHAR(10), THEDATE, 110) AS DATE_LABEL).
I'm guessing the user isn't typing the parameter values in which means that there's already a dataset for the dates. Add another column to the dataset with the date as a date field to use as the Value while using the text as the Label.
If you cannot fix that and still need to convert the text field into a date, you could use the CDATE function which will convert text into a date field.
=Format(CDATE(LEFT(Parameters!DateInfo.Label, 12)),"MM/dd/yyyy")

Qlikview generate qvd by month

i've join two table with left join and will generate the qvd. I would like to generate the qvd based on the month of the date. For example if there are 12 dates from jan to dec, then there will be 12 qvd files.
You can look through all values in the Month field. Each iteration will load data from
TEMP_TABLE1 for one month and store this temp table into a qvd file.
The script below can give you an idea how this can be achieved
// Load some data
RandData:
Load
*
Inline [
Value , Month
1 , Jan
2 , Feb
3 , Mar
4 , Apr
5 , May
6 , Jun
7 , Jul
8 , Aug
9 , Sep
10 , Oct
11 , Nov
12 , Dec
];
// Start looping through each distinct value in the Month field
for i = 1 to FieldValueCount('Month')
// In-loop variable that will get the current increment value from the Month field
let sMonhValue = FieldValue('Month', $(i));
trace Storing data for Month --> $(sMonhValue);
// NoConcatenate is used to tell Qlik to not concatenate the same tables
NoConcatenate
// Load the data for the current iteration month from the main data table
TempTable:
Load
*
Resident
RandData
where
Month = $(i)
;
// Store one month data in qvd. The name of the qvd will include the month value
Store TempTable into RandData_$(sMonhValue).qvd;
// The Store statement above will store the qvd files next to the qvw file.
// If the qvd files need to be stored somewhere else - just provide the path like:
//Store TempTable into c:\users\UserName\Documents\RandData_$(sMonhValue).qvd;
// Drop the temp table. Otherwise it will get concatenated to the "previos" temp table
Drop Table TempTable;
next
// At the end the app will contain only one table - `RandData`

Sorting records based on modified timestamp?

I am trying to sort a list of records that have been created using a screen scraping script. The script adds the following style of date and time (timestamp) to each record:
13 Jan 14:49
The script runs every 15 minutes, but if I set the sort order to 'time DESC' it doesn't really make sense because it lists the records as follows:
13 Jan 14:49
13 Jan 12:32
13 Jan 09:45
08 Feb 01:10
07 Feb 23:31
07 Feb 06:53
06 Feb 23:15
As you can see, it's listing the first figure correctly (the day of the month in number form) but it's putting February after January. To add to the confusion it's putting the latest date in February at the top of the February section.
Is there a better way of sorting these so they are in a more understandable order?
If you are storing the values in a database, simply use the column type datetime when creating the field. The database will treat the field as time and will sort the values chronologically.
Otherwise, if you are storing the values elsewhere, for example in a flat file, convert the formatted time to unix time. Unix time is an integer, thus you can sort it easier.
Time.parse("13 Jan 09:45").to_i
# => 1326444300
Time.parse("08 Feb 01:10").to_i
# => 1328659800
You can always convert a unix time to a Time instance.
Time.at(1328659800).to_s
# => "2012-02-08 01:10:00 +0100"

Getting error ERROR: date/time field value out of range: "31 APR 2001 in Postgres

I have a varchar field where dates are stored in the database where I need data from with values like 31 APR 2001 I run the following query
select date(trim(contact_date)) from clients where date(trim(contact_date)) < '2002-03-12';
Whenever it hits 31 APR 2001 I get the error ERROR: date/time field value out of range: "31 APR 2001
Are there any workaround so that I won't get this error. Since all other dates get return perfectly.
The version of postgres I use is
PostgreSQL 8.1.22
There are 30 days in the month of April.
there is no 31 in April month, prevent it from hitting 31 check it before query