If Statment ( [DateTime in a Sharepoint Column] = Now (), Yes,No )

Curious to know if this is possible, i wish to create an if statment in a sharepoint calculated column where if the date in that row is equal to the time now than mark the column as yes.

The datetime column is called OvertimeDateTime,

This is what i would have normally written anywhere else right?

=IF((OvertimeDateTime)=Now(),Yes,No)

Anyhelp would be ballsriffric

Seriously thanks though, i cant figure it out.

datetime – get the data for the previous day in Python

I am very much new to Python and need to extract previous day data from RESTAPI and in the my RESTAPI request i need to provide QueryStartDate and QueryEndDate. Till now for testing i am providing the previous day date(sysdate-1) manually. But now as i wanted to automated the process, i want to apply Python function to always get the previous date so that i can extract the whole day data from previous day.

"QueryStartDate": "2021-09-02T12:00:00.000Z"
"QueryEndDate": "2021-09-02T12:10:00.000Z"

I tried to apply datetime.now() - timedelta(1) function to get previous day but not sure due to syntax issue the RESTAPI request is throwing an error.

sql server – How can I improve query performance with filter on datetime column using an indexed view?

I have this table:

CREATE TABLE transactions
(
    id                                    NUMERIC(20, 0)              NOT NULL PRIMARY KEY,
    amount                                NUMERIC(18, 2) DEFAULT NULL NULL,
    -- Some 100 columns
    customer_msisdn                       VARCHAR(255)   DEFAULT NULL              NULL,
    customer_email                        VARCHAR(255)   DEFAULT NULL              NULL,
    payment_date                          DATETIME2                   NOT NULL
);

CREATE NONCLUSTERED INDEX msisdn_idx ON transactions (customer_msisdn, payment_date, id);
CREATE NONCLUSTERED INDEX phone_idx ON transactions (customer_phone, payment_date, id);

I’m indexing around ~1m rows a month. Very frequently, I need to select last 3 month’s transactions per customer_msisdn or per customer_email which is 99% time 50 – 1000 records.

Here’s my query for a bit more insight:

SELECT t.*
FROM transactions t
         JOIN (SELECT t.id
               FROM transactions t
                        WITH (FORCESEEK)
               WHERE t.customer_email = :customerEmail
                 AND t.payment_date >= :startDate
                 AND t.payment_date < :endDate
               UNION
               SELECT t.id
               FROM transactions t
                        WITH (FORCESEEK)
               WHERE t.customer_msisdn = :customerMsisdn
                 AND t.payment_date >= :startDate
                 AND t.payment_date < :endDate) AS filtered_transactions
              ON t.id= filtered_transactions.id
ORDER BY t.payment_date;

And I feel like since the :endDate is always now (and when not, can tolerate fault) and :startDate is always three months back, I have some room for improvement. Here’s what I thougt:

Create an indexed view with a filter on payment_date:

CREATE VIEW (dbo).transactions_iv
    WITH SCHEMABINDING AS
SELECT (t).id,
       -- All the rows
       (t).customer_msisdn,
       (t).customer_phone,
       (t).payment_date
FROM (dbo).(transactions) (t)
WHERE (t).payment_date >= DATEADD(MONTH, -3, CURRENT_TIMESTAMP);

and my indexes:

CREATE NONCLUSTERED INDEX msisdn_iv_idx ON transactions_iv (customer_msisdn, id);
CREATE NONCLUSTERED INDEX phone_iv_idx ON transactions_iv (customer_phone, id);

and drop the AND t.payment_date >= :startDate AND t.payment_date < :endDate clauses altogether from the query. The query becomes:

SELECT t.*
FROM transactions_iv t
         JOIN (SELECT t.id
               FROM transactions_iv t
                        WITH (FORCESEEK)
               WHERE t.customer_email = :customerEmail
               UNION
               SELECT t.id
               FROM transactions_iv t
                        WITH (FORCESEEK)
               WHERE t.customer_msisdn = :customerMsisdn) AS filtered_transactions
              ON t.id= filtered_transactions.id
ORDER BY t.payment_date;

Since the view only has last 3 month’s transactions, I’m assuming so will the indexes. Is this assumption correct correct and would I get my performance boost?


Another alternative is:

  1. Create another identical table,
  2. Populate it with a trigger on the main table
  3. With a cron job, delete records older than 3 months every night.

How would this option compare to the previous one?

datetime – Views: Surround Created date field in time tags

When I make a view show a date from a newly created field, it’ll use the time.html.twig template.

Example:
Wednesday, July 28th, 2021 – 17:00 pm

But when I make it show the main date in which the node was created, it’ll just print a string surrounded by span tags.

Example:
Wednesday, July 28th, 2021 – 17:00 pm

I’m guessing I just have to somehow specify that the “created” field has to be printed using the time.html.twig template, but I don’t know how to do that.

How can I make it so the Created field its printed using the time template?

macos – Using Japanese characters in Menubar date/time

I used to be able to set the Menubar date/time to Japanese and the Gregorian calendar (e.g., using the Japanese character for days of week and am/pm), configuring it via the Date/Time panel in Settings, while still using English as my primary language. I’m on Big Sur now and it doesn’t seem like it’s possible to configure this anymore – even if I choose Japanese calendar, it still uses English for the date/time.

Is there a way to do this anymore? Thanks!

asp.net core – How to merge date and time from two separate columns into a new datetime column using csvHelper in C#

I have the following CSV file with the following format.
enter image description here

Using csvHelper in the following code snippet (using Visual Studio 2019), I can successfully read the file.

public ActionResult UploadCsvFile(IFormFile file)
        {
            if (file != null)
            {
                try
                {
                    var basePath = Path.Combine(_hostEnvironment.WebRootPath, "uploads/");
                    if (!Directory.Exists(basePath))
                        Directory.CreateDirectory(basePath);    
                    var filePath = Path.Combine(basePath, file.FileName);
                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        file.CopyTo(stream);
                    }   
                    var config = new CsvConfiguration(CultureInfo.CurrentCulture)
                    {
                        Delimiter = ";",
                        HasHeaderRecord = true
                    };
                    using (var Reader = new StreamReader(filePath))  
                    using (var csv = new CsvReader(Reader, config))
                    {
                        csv.Context.RegisterClassMap<CsvLineClassMap>();
                        var records = csv.GetRecords<CsvLine>().ToList();   
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            return Json(null);
        }

From the debugging window I can see the data records (From there you can see the separate columns of date and time).
enter image description here

But, I need to get as a result in a single column with datetime format, As the following recreated.
enter image description here

I have investigated, but have not been able to solve it.
🙁

python – Datetime não reconhece o strftime

Estou tentando fazer um codigo que recebe uma data no formato de String, desse jeito ‘2021-8-24’, ano mês dia, mas vou converter para data, só que no terminal fala:

data_convertida = datetime.strftime(data_retirada, ‘%Y-%m-%d’).date()
AttributeError: module ‘datetime’ has no attribute ‘strftime’

Ignorem as ultimas duas linhas eu estava tentando converter de AAAA-MM-DD para DD-MM-AAAA

é ja procurei na documentação, é o strftime, faz parte do datetime e não sei como resolver esse problema

import datetime

data_retirada = '2021-8-24'
hora_retirada = '13-12'

data_convertida = datetime.strftime(data_retirada, '%Y-%m-%d').date()
print(data_convertida)
print(type(data_convertida))

year = datetime.data_convertida.year
print(year)```

datetime – Teradata min and max dates Find the Employees Start Date and Time and End Date and Time for each date

I have columns AssignedTo, InternalID, Task Function, Min(STARTDATE), Max(ENDDATE)

AssignedTo InternalID Task Function STARTDATE ENDDATE
Joe 67077 Write the letter 08/24/2017 05:30 AM NULL
Joe 16354 Send the letter 08/24/2017 06:30 am 08/24/2017 07:30 am
Joe 16359 Mail Letter 08/24/2017 08:32 am 08/24/2017 08:35 am
Joe 13340 Call to Member 08/24/2017 09:32 am 08/24/2017 10:35 am
Joe 13318 Fax to Member 08/24/2017 12:01 pm 08/24/2017 12:05 am
Joe 14895 Fax to Member 8/20/2017 11:28:34 PM 8/20/2017 11:28:34 PM
Joe 79806 Call to Member 08/24/2017 03:30pm 08/24/2017 04:30 PM

Trying to create 1 line line this:

Assigned TO: Date: Start Date End Date
Joe 08/24/2017 08/24/2017 05:30 AM 08/24/2017 04:30 PM

I want the first Start Date and last End Date for each day the assigned to is in the system for that day. I’m using teradata. i’m sure this has been asked some where i just have not been able to locate it. Or I have been over thinking this.

spreadsheet – Numbers: How to add or subtract hours for a column with date-time value?

Please note that this questions is about Numbers and not Excel.

Givens:

  • column x has values of format yyyy/mm/dd hh:mm
  • column y has empty values

Desired solution: column y to have values from column x + 9hours

Attemps:

  • In column y, when I do: colxvalue + 9 I get yyyy/mm/(dd+9) hh:mm

What is the correct formula so that in column y the +9 would be added to the hours instead of date?

python – sort a dictonary in datetime field

hello i have a code that gives me dict the dict here is the dict:

{2516: {'order_date': datetime.datetime(2021, 7, 26, 16, 10, 10, 461000), 'product_id': 2516, 
'product_name': 'TRENTO GRIS 30*60 NEW TILE SPAIN 514', 'quantity': -1.0, 'product_cost': 4.0,
'price_unit': 5.5, 'remaining_qty': -23.0, 'seller_name': 'السيد ابو فهد', 'jour': 'Cash,'},

2412: {'order_date': datetime.datetime(2021, 7, 26, 13, 59, 33, 351000), 'product_id': 2412, 
'product_name': 'ORION HEXA SILVER 19.8*22. SPAIN 355', 'quantity': -4.0, 'product_cost': 0.58, 
'price_unit': 1.25, 'remaining_qty': 129.0, 'seller_name': 'السيد برغش المطيري المحترم ', 'jour': 'Cash,'},

2897: {'order_date': datetime.datetime(2021, 7, 23, 20, 4, 2, 939000), 'product_id': 2897, 'product_name': 'BLANCO BR RECT LA 30*60 SPAIN 456', 
'quantity': -6.0, 'product_cost': 3.5, 'price_unit': 4.0, 'remaining_qty': 6.0, 'seller_name': 'السيد احمد منصور العازمي', 
'jour': 'Cash,'},

 2828: {'order_date': datetime.datetime(2021, 7, 23, 20, 8, 38, 380000), 
'product_id': 2828, 'product_name': 'كاونتر مدور رمادي فاتح 1277 (36*12 CM', 'quantity': -1.0, 'product_cost': 0.0, 
'price_unit': 27.5, 'remaining_qty': -1.0, 'seller_name': 'السيد علي المطيري المحترم', 'jour': 'Cash,'}, 

3041: {'order_date': datetime.datetime(2021, 7, 23, 20, 7, 11, 189000), 'product_id': 3041, 'product_name': 'PRIS TINENZA 30*60 SPAIN', 
'quantity': -2.0, 'product_cost': 5.0, 'price_unit': 6.5, 'remaining_qty': -13.0, 'seller_name': 'السيد محمد حسن الكندري المحترم', 'jour': 'Cash,'}}

i tried list comprenhsion like:

                if products_sold.get(line.product_id.id):
                products_sold(line.product_id.id) = sorted(({
                    'order_date': order.date_order,
                    'product_id': products_sold(line.product_id.id).get('product_id'),
                    'product_name': products_sold(line.product_id.id).get('product_name'),
                    'quantity': products_sold(line.product_id.id).get('quantity', 0) + line.qty,
                    'product_cost': products_sold(line.product_id.id).get('product_cost'),
                    'price_unit': products_sold(line.product_id.id).get('price_unit'),
                    'remaining_qty': line.product_id.qty_available,
                    'seller_name': seller_name,
                    'jour': jour
                } for (product, seller_name, order, line, jour), qty in products_sold.get(line.product_id.id)),key=lambda l: l('order_date')

but each time i try this i get a error “ValueError: too many values to unpack (expected 2)”

i even tried like:

dict = {k: v for k, v in sorted(products_sold(line.product_id.id).items(), key= lambda v : v(0))}

and passed it in return still i get error

how to sort this above dictionary i am getting no idea any help will be appreciated, below is a method in which i want the dict to be sorted by “order_date”:

    def get_sale_details_product_wise(self, date_start=False, date_stop=False, configs=False):
    if not configs:
        configs = self.env('pos.config').search(())

    orders = self.env('pos.order').search((
        ('date_order', '>=', date_start),
        ('date_order', '<=', date_stop),
        ('state', 'in', ('paid', 'invoiced', 'done')),
        ('config_id', 'in', configs.ids)))

    products_sold = {}
    for order in orders:
        jour = ''
        jour_list = ()
        for statement in order.statement_ids:
            if statement.journal_id.name not in jour_list:
                jour_list.append(statement.journal_id.name)
                jour += statement.journal_id.name + ','
        for line in order.lines:
            seller_name = self.env("res.partner").search(
                (('id', '=', line.order_id.partner_id.id))).name

            if products_sold.get(line.product_id.id):
                # print('1111111', line.product.id)
                products_sold(line.product_id.id) = sorted(({
                    'order_date': order.date_order,
                    'product_id': products_sold(line.product_id.id).get('product_id'),
                    'product_name': products_sold(line.product_id.id).get('product_name'),
                    'quantity': products_sold(line.product_id.id).get('quantity', 0) + line.qty,
                    'product_cost': products_sold(line.product_id.id).get('product_cost'),
                    'price_unit': products_sold(line.product_id.id).get('price_unit'),
                    'remaining_qty': line.product_id.qty_available,
                    'seller_name': seller_name,
                    'jour': jour
                } for (product, seller_name, order, line, jour), qty in products_sold.get(line.product_id.id)),key=lambda l: l('order_date'))
            else:
                products_sold(line.product_id.id) = {
                    'order_date': order.date_order,
                    'product_id': line.product_id.id,
                    'product_name': line.product_id.name,
                    'quantity': line.qty,
                    'product_cost': line.product_id.standard_price,
                    'price_unit': line.price_unit,
                    'remaining_qty': line.product_id.qty_available,
                    'seller_name': seller_name,
                    'jour': jour
                }
    return {'products': products_sold}