On an ADOQuery I've created a String Tfield and set the it's size to 24(from Fields Editor).
When I'm trying to assign to this field a 24 characters length string (qry.fieldbyname('fieldname').asString), only first 20 characters are added. I don't understand why.
How is the query populated with data? If you are doing a select against a table then the column will have the same width as in the table schema. Check how the column is defined in your database.
Related
I am trying to auto populate fields E3:E99, F3:F99, and G3:G99 based on the text value of fields B3:B99. So when Sam's is inserted anywhere between B3:B99 fields automagically populate with preassigned data. In my case:
E3:E99 will always be 164
F3:F99 will always be 45
G3:G99 will always be 40
Currently am trying to use the following but to no success:
=$B$3:$B$99="Sam's" =$E$3:$E$99="164.00" =$F$3:$F$99="45.00" =$G$3:$G$99=40
and I have it placed in Q3 away from my table so users cannot see it.
What am I missing or not formatting correctly yo auto populate fields based on B3:B99?
I have tried googling as much as possible and have tried a few different appscript methods that did not work.
So I think you will be able to use a simple IF statement logic check combined with an array formula. This is assuming that the values in column B are entered manually. This is the formula to enter into E3. It will automatically check all values in B and output the 124 value when B=Sam's while leaving the value null if it is not Sam's.
=ArrayFormula(IF($B$3:$B$99="Sam's",124,))
This is the formula for F3:
=ArrayFormula(IF($B$3:$B$99="Sam's",45,))
And the formula for G3:
=ArrayFormula(IF($B$3:$B$99="Sam's",40,))
I'm writing a Delphi program that needs to interact with data stored in a SQLite database that belongs to another program. Everything ok so far, except that I'm unable to get the date/time value from the data store in a column in the SQLite database, with the data type 'datetime'.
I do know that the data type of fields is not relevant in SQLite, and that everything is stored as strings, and perhaps that is possibly the reason why I find myself in this predicament.
Below is a sample of a few rows of the data stored in the SQLite database (column 3) vs. the corresponding date value displayed in the program (column 2) that reads and writes to this SQLite database:
1 11/7/1971 621939168000000000
2 3/17/1976 623314656000000000
3 5/4/1996 629667648000000000
4 9/21/2007 633259296000000000
5 11/17/1972 622264032000000000
6 2/7/1996 629592480000000000
7 6/13/2000 630964512000000000
My requirement: Once I read the value in column 3 from my Delphi program, how do I translate it to the same date/time value as displayed in column 2? I have tried the UnixToDateTime function, but it does not result in the same value (as column 2). Can anyone help?
Thanks in advance!
The value in column 3 is the number of 100 nanoseconds since 1/1/0001. You can convert it into a Delphi TDateTime like this:
theDate := (Value/864000000000) - 693593;
I have a query that I need formatted in a particular way, but when I have an 8-character string with a 12-character column name, it pads the column to 12 characters even with Set Heading Off and Set Pagesize 0. Is there a way to display a column such that it will not include the length of the column name when calculating the width to use?
This is not the same as "SQLPlus varchar2 outputs whitespaces", which does not appear to be asking about the case when the column name is longer than the data name - just when the data appears to have an excessive length.
I have Firebird table with field 'ABC' of Time type. I use TMaskedEdit to populate it with mask: !90:00;1;_
It works fine when populating the field with values but does not work properly when displaying values from the field.
I use:
editABC.Text := DateTimeToStr(fieldbyname('ABC').AsDateTime);
The problem I get is that time like for example: 14:48 is displayed as 14:00
Question: how can I display value of field of type Time properly in TMaskedEdit properly?
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.