I have these following data: and the following query that I want to use to find all the entries where the timediff is lesser than 50 hours The second row should be returned because it’s lesser than 50 hours, but the first row, which the timediff is more than 50 hours keep returning as well. It returns all sort of
Tag: date
Should I use Effective Date or Start Date and End Date for historical recording?
I am a Business Analyst and have prepared tables/erd for a system we are implementing. The context is essentially an employee management system, an employee can join the company, change positions, get promoted, demoted, terminated etc. All of this is required to be tracked for filtering and reporting purposes. Therefore we require historical tracking of records. My recommendation and original
Extract day of week from date field in PostgreSQL assuming weeks start on Monday
extract a number from 0 to 6, where 0 is Sunday; is there a way to get the day of the week in SQL assuming that weeks start on Monday (so 0 will be Monday)? Answer From the manual So, you just need to subtract 1 from that result:
Convert iso_week to calendar date in SQL
I’ve been searching though the archives without finding what I am looking for- I’d be happy for some guidance. I have a data set where I want to report aggregated number of appointments by provider (STAFFID) and work week, the latter defined by the week’s Monday date. I’ve played with datepart(iso_week, appointment_date) as week_of_yr which gets me part of the
Error in MySQL when setting default value for DATE or DATETIME
I’m running MySql Server 5.7.11 and this sentence: is not working. Giving the error: But the following: just works. The same case for DATE. As a sidenote, it is mentioned in the MySQL docs: The DATE type is used for values with a date part but no time part. MySQL retrieves and displays DATE values in ‘YYYY-MM-DD’ format. The supported
Rounding dates to first day of the month
I am using SQL Server 2014 and I am working with a column from one of my tables, which list arrival dates. It is in the following format: ArrivalDate 2015-10-17 00:00:00.000 2015-12-03 00:00:00.000 …
Query to sum sales totals for X number of months given dates
I would like to make a query that SUMS the total number of sales of each product ID for a group of months (ie. May – August) I want: +————+————————-+——-+————–+—…
How to see if date is in current month SQL Server?
I have a Ticket_Date column that is in the format YYYY-MM-DD HH:MI:SS I want to check if the Ticket_date is in the current month. So far I have : Ticket_date >= ‘2015-04-01’ and Ticket_date <...
SQL – Get result of current year only
How can I get the result of the current year using SQL? I have a table that has a column date with the format yyyy-mm-dd. Now, I want to do select query that only returns the current year result. The pseudo code should be like: The result should be as following: How can I do this? Answer Use YEAR() to
What is the best method to change Year from YYYY to FYYY format in SQL?
I have year in YYYY format and I want to convert it to FYYY format. So, for instance, 2014 will be FY14, 2009 will be FY09, so on and so forth. I’m creating a View that contains a SUM aggregate …