When creating a table, I would like to set the default value of a char(12) field with todays date. For example, '2016-08-25'
How do I do this in Informix?
If you manage to find the documentation on the DEFAULT clause of CREATE TABLE, then you'll see that the options for what can be a default value are quite limited.
Further, there are type-based restrictions on what's allowed:
CREATE TABLE x(y CHAR(12) NOT NULL DEFAULT TODAY);
This generates the semantic error:
SQL -591: Invalid default value for column/variable (y).
That has the expanded meaning:
The specified default value is the wrong type or is too long for a column
or an SPL-routine variable.
To specify a valid default value for a column, use the DEFAULT clause in a
CREATE TABLE statement. To specify a valid default value for a variable in an
SPL routine, use the DEFAULT clause in a DEFINE statement.
Basically, you can't create a default of TODAY for a CHAR-type column.
It will be much simpler to use a DATE column (where you can apply the default of TODAY validly), and when necessary, select that value as a string. There are some minor details like locale and presentation of the data — you might find DATETIME YEAR TO DAY better than DATE because it enforces the ISO 8601-style notation 2016-08-25 for the values.
Related
I was trying to use the following function;
=INDEX(D:D,COUNTA(D:D),1),
in order to get the last currency value of a column, but it returns #ERROR!.
The value im trying to extract
As I montly update this spreadsheet, it would make it very convenient if would etract the last value in the column, e.g. the value marked in the image.
Is there a way (in Google Sheets) to find the last non-empty cell in this column, such that when I update the spreadsheet with a new "last value" it would return that value?
The index(counta()) pattern will fail when the data is sparse, i.e., when there are blank values in the column.
The index(match()) pattern will fail when the data contains a value that is not a number.
To find the last non-blank value in column D, regardless of data type, use the +sort(row()) pattern:
=+sort(D1:D; not(isblank(D1:D)) * row(D1:D); false)
The formula uses semicolons as argument separators to make it work in any locale.
If the column has only currency (ie number) values then you can use something like:
=INDEX(D1:D, MATCH(999^99, D1:D))
or try:
=SORTN(D:D; 1;;ROW(D:D)*(D:D<>""); )
I have a data set with 77 rows. One of the columns (let's call it C) contains a name value. I would like to highlight the row if the name in column C is found in a list of names in another column.
Currently, I'm able to check only a single value, instead of a list of values. In conditional format rules, I'm able to enter the following formula
=$C:$C=$GU$1
This, of course, only checks the value against the first name in column GU. I tried to add :$GU$100 to the condition, but that won't work as the condition is now checking if the entry is the same as the entire value from GU1:GU100.
I thought I might try to use a FIND() method to see if the substring were in the larger string. To do that, I attempted the following:
=$C:$C=IF(ISNUMBER(FIND($C$1,$GU$1:$GU$100)),1,0)
While this did not return an error, it also did not highlight any rows. I'm unsure how to format one row based on whether or not the value in that row is an entry in a list elsewhere. Any ideas?
Please select your 'entire row' range (here assumed ColumnsA:G) and Format, Conditional formatting..., Format cells if..., Custom formula is:
=match($C1,$H:$H,0)
choose your Formatting style and Done. Where ColumnH is assumed to have your list.
You can add conditional formatting like this with the custom function option and applying to column C, pretending that the list with names your matching against is in column J:
=IF(ISTEXT(VLOOKUP(C1:C,J:J,1,false)),TRUE,FALSE)
Create something like array of values associated with time_stamps, and getting values by time_stamps. only one value with one time_stamp. How better organise it? And how to remove values after goes some time?
something like this:
datetime = os.date("!*t",os.time())
array[datetime]=somevalue
And how to delete from that table values older than 10 minutes?
I don't see why using the date table as keys. You can instead use the timestamp directly as keys, something like:
t[os.time()] = somevalue
The timestamps are only integer values, you can get its real date with os.date when in need.
You can compare them directly. For instance, to remove values that is before May 20, 2014, compare the keys with os.time{year=2014, month=5, day=20, hour=0}.
on Delphi XE2,
I have a ClientDataSet which have many fields as Name, ...
It have a field named Date, as value type String. Containing a Date (dd/mm/yyyy)
I want to print content of ClientDataSet, using FastReport.
I want before to sort content ascending according to the Date field. I'm using index.
But when doing this, sorting does only sorts fields according to the content of the Date string before the "/".
form example dates like : 12/11/2012, 15/10/2012, 01/12/2012 are sorting like this : 01/12/2012 - 12/11/2012 - 15/10/2012.
ny idea how doing this correctly ?!
The sorting is correct! As you have a string field, the sorting is made like strings are sorted i.e. from left to right. If you want it sorted by Date you need either a date field or sort the string representation like yyyy/mm/dd.
You have some options:
Bring the field as a DateTime field. You would have to change the original SQL to that.
Do what Marjan suggested, bringing that string field formatted on an ISO-like style (which allows for the field to be ordered cronologically when string sorting is aplied) and creating an calculated field for user-display formatting.
Creating a new field on the TDatasetProvider's OnGetRecords event and populating it as a Date field.
Similar as above but creating a string field with the date formatted in ISO-Like style.
I personally suggest the first approach if possible.
I have data :- 31-May-07
Its in a calculated column of the list. The method I used to get it :- =IF(FDate="","",TEXT(FDate,"dd-mmm-yy")) {FDate is a DateTime type of column. The returned value is stored in a "Single Line of Text" column type.}
I am now unable to sort that column as its Text now and sorting is done on basis of strings.
I need to sort this column on basis of Date.
Any help ?
Thanks!!
I'm not familiar with Sharepoint but this looks like a pure Excel question. I presume you don't really want to convert the date into text. Let it be a date and just change the cell format.