MS access date format - date

I have an ODBC connection to an informix database from a MS Access database and want to show the time in a query as held in the native database i.e. "dd/mm/yy hh:nn:ss.000". It seems that no matter what format I try in Access I cannot emulate this, although I can do this in MS Excel!?
I've used, amongst others, but to no avail:
Format([startdatetime],"dd/mm/yy hh:nn:ss.000")
Format([startdatetime],"dd/mm/yy hh:nn:ss,SSS")
Any ideas?

Try:
Format([startdatetime],"dd/mm/yyyy hh:nn:ss AM/PM")
If you need to store Access dates to the millisecond, have a look here.

Related

Replaying database load on test instance

I am able to download logs from RDS having queries in the format
2022-09-18 00:00:02 UTC:<host><region>.compute.amazonaws.com(10000):user#db:[20000]:LOG: duration: 0.768 ms statement: Possibly multi line query>
I was suggested to use pgreplay, two things
(1) I want to provide a fixed user for all queries.
(2) The query format above is not compatible.
Is there something can be done or better to write a custom script? Or any alternative tool you would suggest?

Can I modify postgresql sql before execute it

I use grafana to view metrics in timescaledb.
For large scale metrics I create a view to aggregate them to a small dataset, I configure a sql in grafana, which table is fixed, I want the table name is changed according to the time range, say: time range less than 6 hours, query the detail table, time range greater than 24 hours query the aggregate view.
So I am looking for a proxy or postgresql plugin which can used to modify the sql before execute it.
AFAIK there is no PostgreSQL extension to modify SQL query but there is a proxy that says it can rewrite and filter SQL query: https://github.com/wgliang/pgproxy.
You might alternatively look at TimescaleDB's real-time aggregates, which were released in 1.7
Basically it will transparently take the "union" between pre-calculated aggregates > 6 hours with the "raw" data < 6 hours.
Not quite what you are asking for, but might get you to the same place, and works transparently with grafana.
https://blog.timescale.com/blog/achieving-the-best-of-both-worlds-ensuring-up-to-date-results-with-real-time-aggregation/
I would suggest taking a look at Gallium Data, it's a free database proxy that allows you to change database requests before they hit the database, and database responses before they reach the clients.
Disclosure: I'm the founder of Gallium Data.

PostgreSQL database causing loss of datetime-values

I have a PostgreSQL database containing a table with several 'timestamp with timezone' fields.
I have a tool (DBSync) that I want to use to transfer the contents of this table to another server/database.
When I transfer the data to a MSSQL server all datetime values are replaced with '1753-01-01'. When I transfer the data to a PostgreSQL database all datetime values are replaced with '0001-01-01'.
The smallest possible date for those systems.
Now i recreate the source-table (including contents) in a different database on the same PostgreSQL server. The only difference: the sourcetable is in a different database. Same server, same routing. Only ports are different.
User is different but in each database I have the same rights.
How can it be that the database is responsible for an apparant different interpretation of the data? Do PostgreSQL databases have database-specific settings that can cause such behaviour? What database-settings can/should I check?
To be clear, I am not looking for another way to transfer data. I have several available. The thing that I am trying to understand is: how can it be that, if an application reads datetime info from table A in database Y on server X, it gives me the the wrong date while when reading the same table from database Z on server X will give me the data as it should be.
It turns out that the cause is probably the difference in server-version. One is a Postgres 9 (works ok), the other is a Postgres 10 (does not work okay).
They are different instances on the same machine. Somehow I missed that (blush).
With transferring I meant that I am reading records from a sourcedatabase (Postgresql) and inserting them in a targetdatabase (mssql 2017).
This is done through the application, I am not sure what drivers it is using.
I wil work with the people who made the application.
For those wondering: it is this application: https://dbconvert.com/mssql/postgresql/
When a solution is found I will update this answer with the found solution.

Making MS Access queries that allow data entry to PostgreSQL database via an ODBC driver

I've been asked to modify an Access database by putting the data themselves into a Postgres database while keeping the old Access file as a frontend. So far everything has worked just fine, with every linked table, query and form working just like before when viewed.
The issue is, however, that all of the forms call on MS Access queries which users can insert data into, but after the tables have been migrated into PostgreSQL, those queries no longer allow for data inserts, which means the forms no longer allow for data inserts. I can edit the rows already entered, but I cannot make new rows, and I can insert new rows into the linked tables. This is as a superuser.
I have made Access queries in the past that allowed for data entry to a Postgres database, but I don't have access to those files now, and I can't for the life of me figure out what I did diferently back then.
Highly appreciate any leads. Couldn't find anything on this. Using MS Access 2010 and PostgreSQL 9.1
Solved
Andre pointed out that these MS Access queries must include the primary key to give the option of creating new rows. Once I added the id field to the query, the forms worked like they did before.
The answer, supplied by Andre, is that simple MS Access queries allow for inserts into PostgreSQL if the queries include the primary key of the queried table. Cheers!

MongoDB query database for time

Is there a way to query mongodb in such a way that I can retrieve the time?
I often do a check where I check the time the mongodb server is running on before putting data on. I need to know the time on the db server from the point of view of a client.
I'm using the C# .NET wrapper, but if there is a query that can do this on any platform that would be nice too. How would would I get the db time?
I know there are obviously other ways to do this, by synchronizing times. But I need to use this option so there can be no tampering with the local time
db.hostInfo() returns an object where system.currentTime is the current time on the server's host.
I'm not sure what you mean by "from the point of view of a client". But, this might help:
>> db.serverStatus()
returns a big object, which includes the time. Apparently (haven't tested this), for the java driver you can get this with Db.command("serverStatus"), so I would imagine something similar works in C#.
References:
Mongo docs for serverStatus
An answered question about serverStatus in Java