Home » Developing U++ » U++ Developers corner » Date emulation for Sqlite
|
|
|
Re: Date emulation for Sqlite [message #5294 is a reply to message #5291] |
Tue, 12 September 2006 20:07 |
|
The only problem with sqlite is when you select "stringed dates" into value and you want that value to be date type.
Now I use ScanDate which seems to work well.
Value dt = ScanDate(String(SQL[DT])); //DT column that holds date
Date ScanDate(String &s)
{
if(s.IsEmpty())
return Null;
int year = atoi(s.Left(4));
int month = atoi(s.Mid(5, 2));
int day = atoi(s.Right(2));
return Date(year, month, day);
}
But I agree that is troublesome and your chage is wanted.
[Updated on: Tue, 12 September 2006 22:24] Report message to a moderator
|
|
|
Re: Date emulation for Sqlite [message #5295 is a reply to message #5293] |
Tue, 12 September 2006 20:33 |
|
mirek
Messages: 13984 Registered: November 2005
|
Ultimate Member |
|
|
zsolt wrote on Tue, 12 September 2006 12:28 | My problem with this special double is that it would break two things:
1. Internal sqlite date operations as Ulti pointed to that
2. the readability of the result of a simple sql select.
I don't know well the logic of sch files yet, but wouldn't it be possible to use them to get the type of a column?
|
1. can be to large degree solved by SqlExp. In fact, it is "timestamp" type in disguise...
2. OK, this has not come to my mind, that is valid concern. OTOH, it affects non-U++ tools only. In U++, you would be able to get correct dates only.
What about to be a little crazy and encode Date(2006, 9, 12) as 0.20060912e300 ?
Anyway, any other ideas how to store Date into Sqlite?
The only other one that I have is to store it as string with prefix - that however would mean to introduce some trouble to regular strings as well.
Well, I guess I owe the reason why that is so important. The thing to solve is that you cannot now with Sqlite associate EditDate with Sqlite column. Especially troublesome with SqlCtrls or SqlArray.
Mirek
|
|
|
|
|
|
|
|
|
Re: Date emulation for Sqlite [message #6763 is a reply to message #6762] |
Sun, 26 November 2006 18:24 |
zsolt
Messages: 698 Registered: December 2005 Location: Budapest, Hungary
|
Contributor |
|
|
Quote: | EditDate not work with SqlCtrl and Sqlite, but you can make new ctrl like SqlEditDate which work with date like "yyyy-mm-dd" in sqlite table.
|
This is very good idea.
But I think, the main problem is, that it doesn't resolve the Value problem. The Value class is typed internally, and the problem is, that in the core of SQL classes you can not set Value instances correctly, because SQLite doesn't report date types in metadata of query results.
|
|
|
Goto Forum:
Current Time: Wed Jun 05 10:05:31 CEST 2024
Total time taken to generate the page: 0.01910 seconds
|