System timezone and DB2 timezones are not matching.
Current system timezone is -5000 and db2 gives me back -40000 with the following query
select CURRENT_TIMEZONE from SYSIBM.SYSDUMMY1
how and where can I set this value?
I hope it could help SELECT DBNAME, TSNAME, DSNUM, ICTYPE, TIMESTAMP - CURRENT TIMEZONE
FROM SYSIBM.SYSCOPY;
I've found a way, I had to restart the database instance.
db2 force application all
db2stop
db2start
Related
I have a document that has been generated, say, on 2017-10-03 15:02:47.
Then I have this Rails/SQL query (it doesn't matter if I run it through Rails or straight through the SQL console, the results are the same):
SELECT * FROM table where needed_column <= '2017-10-03';
This query would not return me the document that has been generated on 2017-10-03 15:02:47. If I do run, though, this query:
SELECT * FROM table where needed_column <= '2017-10-03 23:59:59';
Then I get the needed document (generated on 2017-10-03 15:02:47).
To solve this issue, I can manually add the time to the query (23:59:59), but it's not a very elegant solution.
I am using Rails 5, AR, PostgreSQL - is there a better way to solve this problem than to manually add the time stamp to the query?
Thank you
Your needed_column is probably saving timestamps (Date and Time). As you already figured it out you need to compare it with another timestamp or cast needed_column using ::date
Model.where("needed_column::date <= '2017-10-03'")
This will generate:
SELECT table.* FROM table WHERE (needed_column::date <= '2017-10-03')
Try this in Rails:-
Model.where(needed_column: [Time.now.at_beginning_of_day, Time.now.end_of_day])
Or as sql query:-
SELECT * FROM table_name WHERE needed_column BETWEEN '2017-10-09 00:00:00 UTC' AND '2017-10-09 23:59:59 UTC'
I want to run a query on a remote database with a timeout option.
For example :
Select * from XYZ table
if this query does not return any result within 2 min then automatically stop this query process.
dummy psql
#timeout select * from XYZ
is it possible to pass timeout parameter at run time without touching any conf file?
In psql use statement_timeout(n) where n is in milliseconds. Or you can set statement_timeout in postgresql.conf but it will affect all sessions.
Is there a way to find all the stored procedures that have been executed in last 24 hours? I need to show:
time of the execution for the current stored procedure
whole text of the stored procedures
I am using SQL Server 2012. I have edited my question. I will be happy if I am able to show only these two columns!
I guess the sys tables might be helpful...
select o.name, eps.last_execution_time
from [sys].[dm_exec_procedure_stats] eps
join [sys].[objects] o ON eps.object_id = o.object_id
where last_execution_time >= dateadd(HH, -24, getdate())
I have a datetimeoffset field in a SQL Server table that stores datetimes from a variety of timezones. Here is an example
2015-02-05 21:43:20.7660000 +13:00
Using the activerecord-sqlserver-adapter (version 3.2.0) gem, I connect to this SQL Server instance and query the table. When I get a result, it seems the offset is being stripped and set to either UTC or local time. Here is an example
> Event.maximum(:timestamp_of_event)
=> 2015-02-05 21:43:20 UTC
ActiveRecord::Base.default_timezone is set to :utc and I can set it to :local but really I want :whatever_is_stored_in_the_table.
How can I get the adapter to read in the offset as stored in the database? Is this possible? Or maybe I could define the type of this column as string and do the parsing all in code?
I want to use column aliases while selecting the column in an informix database table.
For example in the following query:
SELECT hire_dt as "Hire Date" FROM employee
Column hire_dt should be displayed as Hire Date. How can I do this in informix?
This is fine as long as you have the DELIMIDENT environment variable set. Read up about it in the documentation.
In you connection string you can use:
Database=mydatabase;Host=192.168.100.1;Max Pool Size=3;
Min Pool Size=1;Pooling=True;Protocol=onsoctcp;Password=informix;
Server=ol_server;Service=1256;User ID=informix;delimident=y
delimident=y