View previous topic :: View next topic |
Author |
Message |
JustVoodoo
Joined: 17 Jan 2012 Posts: 4
|
Posted: Wed Jan 18, 2012 12:12 Post subject: No respose from "SELECT datetime('now');" |
|
|
I tried it with SQLiteBrowser an it works.
The logile says "o Got request: SELECT datetime('now','localtime');" but I do not get a response...
A work around is to make an entry for the Date and then "select * FROM x WHERE Id=1" or s.t. like that, but isn't there a way to get that response?
BTW: Does anyone knows a solution for that strftime('%s', 'now') problem? The % will be replaced with ~ and thats pretty bad. Especially because I need the current Day of the Week ( strftime('%W', 'now') ) ...
Any other ways to get the Day of the Week will be fine as well
Thx for Help |
|
Back to top |
|
|
Lokey
Joined: 02 Jan 2005 Posts: 158
|
|
Back to top |
|
|
JustVoodoo
Joined: 17 Jan 2012 Posts: 4
|
Posted: Fri Jan 20, 2012 17:42 Post subject: |
|
|
Hi Lokey,
thx for your answer but I guess that that functons are for MySQL not for SQLite. Even in QueryBrowser it says "no such function".
Or is that a function from NWNX (that translate this into SELECT datetime('now') ?).
BTW:
I did the workaround just a few minutes ago. Since I needed some other timefunctions like strftime('%s','now') and strftime('%W','now') and you can't use "%" in a string in NWScript (because some mechanics I dont know translate every "%" in "~", there is another topic about that issue).
So I am using a TRIGGER like this:
Code: |
CREATE TRIGGER update_timestamp AFTER UPDATE OF value ON module
BEGIN
UPDATE module SET value = strftime('%s',(SELECT value FROM module WHERE variable='ActualTime'),'localtime') WHERE variable='ActualTimestamp';
UPDATE module SET value = strftime('%w',(SELECT value FROM module WHERE variable='ActualTime'),'localtime') WHERE variable='ActualTimeWeekOfYear';
END;
|
I am using a table "module" with 2 columns "variable" and "value", to store some stuff for my module. Three rows are used for my time thing.
ID,variable,value
1, ActualTime, 2012-01-01 00:00:00
2, ActualTimestamp, 1325376000
3, ActualTimeWeekOfYear, 0
Everytime I update ActualTime, the other 2 Rows will be updated by the trigger and then I can read that values with the normal DBReadString command from NWNX. |
|
Back to top |
|
|
Lokey
Joined: 02 Jan 2005 Posts: 158
|
Posted: Sat Jan 21, 2012 1:00 Post subject: |
|
|
Sorry reading fail. There's certainly sqlite manuals around, spitting out time shouldn't be too hard (failing that there's other modules that give access to environment). _________________ Neversummer PW NWNx powered mayhem |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|