How to change pgsql now() time? - windows

I'm having an error on my system with some timescale matherialized views, but this only happens after 22 hrs.
I canĀ“t access the office's computer at that hour and I should not be working at that time, so for me to debug the problem I would like to change the computer's time to pretend it's 22 at 9 am.
I changed the computer's time and restarted the psql docker image, but it still marks the current time when select now().
I can find many posts and documentation about changing the timezone, but I just want the server to belive that current time is today's late night.
Is there any way for doing this?
thanks
ps: I'm working on windows 10, and pg12.

You can change the time of your session, so that you can perform your tests, e.g. current time - 5 hours
SELECT now();
now
-------------------------------
2022-02-03 13:01:35.580786+00
(1 row)
SET timezone = -5;
SELECT now();
now
-------------------------------
2022-02-03 08:01:47.569613-05
(1 row)
Demo: db<>fiddle

Related

Can i get the 2 hour digits in Oracle Business Intelligence using HOUR()?

I'm trying to get the hour from a timestamp column, i use the HOUR() funtion and im available to get it but i need to get the 2 digit hour.
This is what i already try:
HOUR("Column.Name")
This is what i get in my output, do not worry about the minutes:
For example in my output i have 7:00 and 9:30, after using the HOUR function i would like to get 07 and 09 instead of 7 and 9.
Anyone can help me?
select LPAD(extract(hour from SYSTIMESTAMP),2,'0') from dual;
You can use the Oracle extract functionality which extracts hour from a TIMESTAMP field.
Note : It does not work with DATE datatype only TIMESTAMP should be an input parameter
Oracle Reference : https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions052.htm#SQLRF00639

user must login with in entered time interval

I have to restrict user login to my application based on the start time( just hour value) and end time(just hour value) they entered. I am storing those values in 1 ... 24 hour format. The query I'm running is.
select * from table WHERE startHour <= '10' and endHour >= '10'
(10 is current hour). This is not working if user enters end time and start time as 1. Can you guys help me the current way I need to work.
I have some questions. Are the start time and end time only in hours? Also, is it valid if the start time and end time are given the same values? That would mean that the user has to log in at the exact hour inputted and no leeway for minutes past or minutes before. Can you post the structure of your table containing the start time and end time entries?
Also, when you say it's not working, can you give the scenario of what occurs by then? Provide any exact error or issue.

Compare Data before storing in New Database from Last Value, Last 15 Min Value, and Previous Day Value

Friends,
Currently i m doing following....
i have a oss database from where i am fetching cpu usage value in 5 min interval and storing this value in my local ms access database. in ms access database im storing date, time, cpu usage,unit name in a table called "tblCdata".
im doing this by some application which i written in Visual basic 2010.
Q.i want to compare the cpu usage with the Last Value, Last 15 min value and Last Day value and generate an Alarm(that i will show in my VB application.) when it cross some threshold which is 50%??
plz guide me how to do it....
You can use
DateAdd("s", -15 * 60, Now())
to look up the record with max of logging time smaller than this.
Likewise
DateAdd("n", -24 * 60, Now())
for the day old log.
Or, if you create the variables in VB.NET, respectively:
DateTime.Now.AddMinutes(-15))
DateTime.Now.AddDays(-1))

Catalog Price Rules are set in the past

I have a very weird problem with Catalog Price Rules. As you know normally when price rules are applied, they are applied for current day, past day, and next day.
The problem is that the price rules are generated only for current day, and two past days.
So if taking today example on catalogrule_product_price on rule_date row the dates set are:
2014-03-12
2014-03-13
2014-03-14 - today date
Instead of:
2014-03-13
2014-03-14 - today date
2014-03-15 - tomorrow
Any suggestions?
This happens when your database is using a different time zone to your Magento site. You need to check and verify that they are both using the same time zone.
For Magento you can check this from System -> Configuration -> Locale Options.
For your database, you can run the following query to the the current local time: SELECT NOW();
If these don't match then you will get the behaviour described above (rules are not correctly set +/- current day). Most likely you need to correct the timezone that your database is using.
Edit: it seems that the best way to handle this is to ensure that you set the global timezone to UTC in Magento, and then set the timezone for your individual site(s) to the local time in your region. Your database should also be set to default to UTC.
Edit 2: Also make sure that the default locale set in app/etc/config.xml is correct.
Could it be related to time zones? Either the time zone of your server clock or the time zone set in Magento?
Try setting your Default Store Timezone to match your server timezone.

TFServer : Cannot update data because the server clock may have been set incorrectly

I am working on project which is on the TFServer. every thing was fine till today which the server time changed to 4 hours ahead. i cann't check in any thing from then because i get the following error
TFS2010 TF54000: Cannot update data because the server clock may have been set incorrectly. Contact your Team Foundation Server Administrator
i searched in internet i found this
http://www.windows-tech.info/4/d1a37cfc6cf38a79.php
so i look into the tbl_Changeset i have two records for today
780 1 2013-12-09 11:13:56.930 807 1
781 1 2013-12-09 11:16:40.727 808 1
i am writing this post on 14:00 which definately bigger than 11:13, so i couldn't checkin again?
This usually occurs when changesets have future times, possibly due to a system clock being temporarily set in the future. To fix it, first run this query against the relevant collection DB (e.g. Tfs_DefaultCollection):
SELECT TOP 20 *
FROM tbl_ChangeSet
ORDER BY CreationDate DESC
You will probably see a row with a CreationDate in the future
Update the errored rows to a sensible time in the past:
UPDATE tbl_ChangeSet SET CreationDate = '2014-07-10 05:51:04.160' WHERE ChangeSetId = 73
That happens when the TFS server clock has been tampered. A common scenario is the server clock changed backwards after a check-in has been submitted. The times you see on tbl_Changeset are in UTC. You can try modifying the records several hours backwards, i.e.: from 2013-12-09 11:13:56.930 to 2013-12-09 00:13:56.930
About TFS Clock Error: It happens when your server machine time changed and you at time of Checkin & Checkout it put dates according to server in SQL Server Database hosting TFS Porject Collection. It update multiple tables not only tbl_ChangeSet or tbl_PendingChangeSet. I got it working by updating dates in multiple tables. What I did is mentioned below:
///Generated Script at once for all table for field data_type='datetime' Please see image below.
After above part: I copied Resutl Script to new query window and make it Common Table expression to limit the list accordingly. See Image Below.
See the result below: You will have list of tables with field name you need to update if date is mismatch. Changing of date you can do it with TSQL Query or can manually change directly editing in table.
Note: Please take your database Backup first. :) Enjoy!!!

Resources