What will be the cron expression for every 2 hour on cronos? I am using 0 */2 * * * but its not working - asp.net-core

I am using 0 */2 * * * cron expression for every 2 hours but its not working. I am using cronos for cron job. So what will be the cron expression for every 2 hour on cronos?

Related

Converting an nvarchar into a custom time format to query upon duration

I am working with a table that has a variety of column types in rather specific and strange formats. Specifically I have a column, 'Total_Time' that measures a duration in the format:
days:hours:minutes (d:hh:mm)
e.g 200:10:03 represents 200 days, 10 hours and 3 minutes.
I want to be able to run queries against this duration in order to filter upon time durations such as
SELECT * FROM [TestDB].[dbo].[myData] WHERE Total_Time < 0:1:20
Ideally this would provide me with a list of entries whose total time duration is less than 1 hour and 20 minutes. I'm not aware of how this is possible in an nvarchar format so I would appreciate any advice on how to approach this problem. Thanks in advance...
I would suggest converting that value to minutes, and then passing the parametrised value as minutes as well.
If we can assume that there will always be a days, hours, and minutes section (so N'0:0:10' would be used to represent 10 minutes) you could do something like this:
SELECT *
FROM (VALUES(N'200:10:03'))V(Duration)
CROSS APPLY (VALUES(CHARINDEX(':',V.Duration)))H(CI)
CROSS APPLY (VALUES(CHARINDEX(':',V.Duration,H.CI+1)))M(CI)
CROSS APPLY (VALUES(TRY_CONVERT(int,LEFT(V.Duration,H.CI-1)),TRY_CONVERT(int,SUBSTRING(V.Duration,H.CI+1, M.CI - H.CI-1)),TRY_CONVERT(int, STUFF(V.Duration,1,M.CI,''))))DHM(Days,Hours,Minutes)
CROSS APPLY (VALUES((DHM.Days*60*24) + (DHM.Hours * 60) + DHM.Minutes))D(Minutes)
WHERE D.[Minutes] < 80; --1 hour 20 minutes = 80 minutes
If you can, then ideally you should be fixing your design and just storing the value as a consumable value (like an int representing the number of minutes), or at least adding a computed column (likely PERSISTED and indexed appropriately) so that you can just reference that.
If you're on SQL Server 2022+, you could do something like this, which is less "awful" to look at:
SELECT *
FROM (VALUES(N'200:10:03'))V(Duration)
CROSS APPLY(SELECT SUM(CASE SS.ordinal WHEN 1 THEN TRY_CONVERT(int,SS.[value]) * 60 * 24
WHEN 2 THEN TRY_CONVERT(int,SS.[value]) * 60
WHEN 3 THEN TRY_CONVERT(int,SS.[value])
END) AS Minutes
FROM STRING_SPLIT(V.Duration,':',1) SS)D
WHERE D.[Minutes] < 80; --1 hour 20 minutes = 80 minutes;

Postgresql - Query to multiply time by number

I'm creating a query to multiply a time by a number.
The time is the result of a query of the annual working hours of a person. The purpose is calculate the 25% then I want to multiply the time by 0.25
Example:
Time1: 100:00:00
[format H:M:s]
For this I've tried this query:
SELECT '100:00:00'::time * 0.25
PostgreSQL returns:
ERROR: the time / date value is out of range: «100: 00: 00»
LINE 2: SELECT '100: 00: 00' :: time * 0.25
The error is clear. My conversion of the time is out of range because the time object only is valid to 24 hours. In this case is working fine:
SELECT '24:00:00'::time * 0.25
Result:
"06:00:00"
Someone have any idea?
Time values are limited to 24 hours. You can do the calculation using other units. For instance, the following translates this to seconds:
select 0.25 * ( (string_to_array('100:00:00', ':'))[1]::int*60*60 +
(string_to_array('100:00:00', ':'))[2]::int*60 +
(string_to_array('100:00:00', ':'))[3]::int
) as num_seconds
Note that you also cannot represent the result as a time
You can use an INTERVAL, as in:
select interval '100 hours 0 minutes 0 seconds' * 0.25
or:
select interval '100:00:00' * 0.25
or:
select '100:00:00'::interval * 0.25
The result (for all of them):
?column?
--------
25:00:00

Takes more time between two dates in postgresql

While running the following query in postgresql
SELECT *
FROM transactions.transactions_view
where gl_account_id=246
it takes only 150 msec
But
SELECT *
FROM transactions.transactions_view
WHERE gl_account_id=246 AND tran_date between '2018-05-01' AND '2018-05-24'
It takes more than 9 minutes. What is the problem?

Hybris: how to schedule cornjob to work from 7am to 11pm?

How to schedule cron job in Hybris, so that it triggers every hour between 7 am and 11 pm?
You can make use of a cron expression generator :
https://www.freeformatter.com/cron-expression-generator-quartz.html
Expression : 0 0 7-11 ? * * *

SQL Server DATEDIFF keeps ignoring seconds part of date

I am getting 0 on executing the following statement:
SELECT DATEDIFF(mi,'1970-01-01 00:00:00','1970-01-01 00:00:01') * CONVERT(BIGINT,60)*1000 as BidTicks
Whereas I get 6000 on executing this:
SELECT DATEDIFF(mi,'1970-01-01 00:00:00','1970-01-01 00:01:01') * CONVERT(BIGINT,60)*1000 as BidTicks
What are my options?
You need to use s or ss for your expected output .
select DATEDIFF(s,'1970-01-01 00:00:00','1970-01-01 00:00:01') * CONVERT(BIGINT,60)*1000 as BidTicks
it will prodece :
60000
To return the difference in seconds as the first argument in your query, you'll want to use seconds as the argument, which is an s:
select DATEDIFF(s,'1970-01-01 00:00:00','1970-01-01 00:01:01')
Basically, your query is asking for the number of minutes between the two. Your first query returns 0, the second returns 1.
Therefore 0 * 60 * 1000 = 0 and 1 * 60 * 1000 = 60000
Try the following:
select DATEDIFF(s,'1970-01-01 00:00:00','1970-01-01 00:01:01')
-- * convert(BIGINT,60) wasn't sure if this was necessary still
* 1000 as BidTicks
Use s or ss instead of mi
select DATEDIFF(s,'1970-01-01 00:00:00','1970-01-01 00:00:01') * CONVERT(BIGINT,60)*1000 as BidTicks
datepart | Abbreviations
------------+---------------
hour | hh
minute | mi, n
second | ss, s
millisecond | ms
microsecond | mcs
nanosecond | ns