Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [date]

Questions related to date or date-related functions, data-types, representations (how dates might be stored and displayed) and operations (such as subtracting dates, adding intervals to dates).

0
votes
2answers
46 views
+50

How can I use mysql to determine the Sundays for the last year?

I have a table where I'm currently aggregating ~200 rows per day of stats. These stats include things like # of users, how many people using X feature, etc. What I'd like to do is query this table ...
1
vote
2answers
64 views

Insert missing dates within table

I have a table with a column for ID, Date and Frequency of occurrence for that particular date and ID. ID date Frequency 1 2014-05-18 5 1 2014-05-19 4 1 2014-05-20 ...
1
vote
1answer
59 views

Select within or closest to date range MSSQL

Lets say we have a table CREATE TABLE [dbo].[Product]( [ProductId] [int] NOT NULL, [Name] [varchar](50) NOT NULL ) CREATE TABLE [ProductPrice]( [ProductPriceId] [int] NOT NULL, [...
0
votes
0answers
7 views

Creating a database for due dates

In my current role I have to write down all my projects on pre-made grid on a dry erase board. As I finish a project I erase it but as the board reaches its capacity I have to manually shift ...
0
votes
1answer
33 views

finding the most recently updated record with multiple date columns

I have recently inherited a SQL Server 2016 database which was converted from an old MS Access db. I have a table that shows various repair dates and test dates for associated serial numbers. I would ...
2
votes
2answers
26 views

Converting and Subtracting Two Dates

I'm trying to get the numeric difference between two dates. (Ex: 11/30/2018 - 11/05/2018 = 25) One of the dates (@EndOfMonth) represent the last day of the prior month and is being converted into a ...
2
votes
1answer
44 views

Sum values by time

id_ | date_ | hour_ | in_|out_| |…. | …. | …. | …. | …. |19 | 2018-12-12| 18:15:00| 1 | 3 | |19 | 2018-12-12| 18:30:00| 1 | 0 | |19 | 2018-12-12| 18:45:00| 2 | 4 | |...
0
votes
2answers
39 views

Getting Records with Min Max Value on Grouped in Single Table in postgresql

The table looks like this: Existing Table: table_1 Desired Result: table_1 I have been able to get result like the following using this code: table_1 But I would like to get minimum and maximum ...
0
votes
1answer
24 views

how to convert a date string like this MM/YYYY to 01-MM-YY

I have a column and its type is string and stores date something like this 03/1996 I want to convert that to 01-MAR-96? how can I achieve that in ORACLE
0
votes
1answer
57 views

Generate Dates between Date Ranges in mysql

Is there a way to generate dates between date ranges. After looking on SO I found out there is a way to use CTE, another option is to use Union All from 0 to 9. Is there an inbuilt function which I ...
5
votes
3answers
262 views

Getting SQL server to recognise a date column

I am trying to get a count of IDS on a orders table for yesterday (not hardcode) where the date in the table corresponds to when the order was placed. My table looks like this orders ( order_id INT ...
1
vote
1answer
144 views

Select data from the previous 3 months [duplicate]

I need help selecting data where the date is in the previous 3 months. (note: I'm not asking for the last 3 months i.e. DATEADD(MONTH, -3, GETDATE()) ) The reason I don't want to use the DATEADD ...
-1
votes
1answer
26 views

MySQL - Classic Date Functions

Version: 10.2.18-MariaDB I'm attempting to find the first available room within December (already included in the sample table) that will be free for 3 consecutive days. The expected output should ...
1
vote
1answer
34 views

Searching through dates query not working?

I'm trying to query the recent week rows by using dates. BUT the query is not returning any result. It takes forever to execute. I checked my DataBase where date is saved in 1446976737 format which ...
0
votes
1answer
27 views

SAP BO Freehand SQL date formatting (Oracle db)

My original query worked perfectly via SQL Developer: select * from [table] where DT_CURRENT_DT = '15-OCT-18' However when ran via freehand SQL in SAP BO I got no results. After running the query ...
1
vote
2answers
65 views

Fiscal Year dynamic function (Oracle SQL)

My Fiscal Year starts on 1st October (2017) and ends 30th September (2018) I want to write a function that will dynamically calculate first day of October. Currently I have: select Add_Months(Trunc(...
0
votes
1answer
60 views

Fiscal Year to Date filter

This is my data: I need a Fiscal Year to Date logic that will gather all previous months starting October. However, for October 2018 I want to start form 15th, for remaining years it must start from ...
0
votes
1answer
17 views

postgres - node-postgres client does not return rows with between clause for dates

I have a view created as shown below. CREATE OR REPLACE VIEW aggr.v_param_data AS select date(a.received_timestamp) run_date, a.mId, min(a.param_value) min_value, max(a.param_value) max_value, ...
2
votes
1answer
63 views

Filtering previous month data with case statement

These are my available attributes: DT_CURRENT_DT Month Year 11-OCT-18 10 2018 12-OCT-18 10 2018 13-OCT-18 10 2018 14-OCT-18 10 2018 15-OCT-18 10 2018 16-OCT-18 ...
0
votes
1answer
77 views

select Data between two date range mysql return wrong values

I want to select data between 9/Nov/2018 and 11/Nov/2018, but the result seems wrong - it returned data outside the two ranges. Using the below query... select * from radacct where DATE_FORMAT(...
1
vote
3answers
46 views

PL/SQL date or to_char question

begin if TO_CHAR('23-OCT-1994','DAY') = 'FRIDAY' THEN DBMS_OUTPUT.PUT_LINE('FRIDAY'); else DBMS_OUTPUT.PUT_LINE('Not Friday'); end if; end; / I am trying to ...
-1
votes
0answers
40 views

Optimise empty date filling query (using a calendar table)

I don't know if it's possible but I'd like to optimise a query I wrote to get all groups of a query between two dates filled with 0 values for missing date in the interval. I'm running MySQL 5.7 I ...
0
votes
1answer
27 views

How do I generate a date series in PostgreSQL without hard coding the dates? [duplicate]

I want to generate a series of months. The start should be the first month of the current year, the stop is the current date with an interval of 1 month. I used the function generate_series (see ...
2
votes
1answer
74 views

SET DATESTYLE TO 'European'; in MySQL

I'm doing MySQL exercises and I found some of PostgreSQL, and there is a part where before entering the data to the newly created tables, enter that command, SET DATESTYLE TO 'European'; I tried to ...
1
vote
0answers
17 views

Query that fetchs average values over timestamp range of time, on a certain value of another pair of fields

This is the situation, over the time our table reached around 800 millions rows. And it is going to get bigger and bigger. It is a service that collects metrics of energy (voltage, power, current, etc)...
0
votes
1answer
94 views

Select records based on earliest date in a linked record

I am a retired teacher working on my first MYSQL database as a personal project; please let me know if I've inadvertently violated conventions. And thank you! The database's domain is fiction stories,...
1
vote
1answer
39 views

What is the function that determines the maximum value in a series?

Say I have a table with columns C and D (among others but these are the relevant ones) with the date type. I am instructed to update the values in C to be 90 days before its corresponding value in D, ...
3
votes
1answer
584 views

Convert YYYY-MM-DD date (without time zone) to unix timestamp in Postgres

I've got a column of type date with the following value format: YYYY-MM-DD (eg. 2018-08-03). I want to get the unix timestamp equivalent of the dates, but without the timezone. F.e. the date 2018-08-...
1
vote
1answer
45 views

How to compute a membership expiration date on SQL

This is a follow up to this previously posted question. I'm using LibreOffice Base to work with some membership data. Further expansion might be possible in the future, but for now, the embedded ...
0
votes
1answer
541 views

Converting unix timestamp to an sql timestamp in postgres

I have passed Date.now() and other plain unix timestamps like 1534360109480 into sql and ran them through this. "@converted_date" = to_timestamp("@date") AT TIME ZONE 'UTC'; And it consistently ...
0
votes
0answers
22 views

Postgresql 9.4 input invalid for type date “”

I have postgresql94-server.x86_64 (9.4.17-1PGDG.rhel6) installed on CentOS 6, and a database where SELECT idprovv as idprovv_look, (case when datacdm is null then '31/12/2020' else datacdm end)::...
0
votes
1answer
123 views

How to create a trigger in oracle to prevent insert dates

I'm learning Oracle and I had a problem. Chat table: CREATE TABLE training ( id_training NUMBER, id_user NUMBER, start_training DATE, end_training DATE ); I want to ...
-2
votes
3answers
102 views

How to list the table based on week or month from range of dates?

I'm using MySQL. I have a table attendance which looks like Now i'm trying to display the leaves w.r.t. manager id using the query select att.mgr_assc_fk, att.id_emp_fk, sum(case when leave_typ = '...
1
vote
1answer
49 views

Finding which DATE columns have no time data using TRUNC

I'm in the process of converting an Oracle db to a PostgreSQL one. The script I used converted all Oracle's DATE columns into TIMESTAMPS, but I suspect that most of those do not hold any time data ...
1
vote
1answer
28 views

datetime row created

I have sqlserver DB , and there I have few tables. I have 1 table that not save each row what is the datetime the each row created. Is there any way to know when which row was created? Is there any ...
1
vote
2answers
2k views

What is the CURRENT_DATE or current date value function for SQL Server?

What is the SQL Server functionality that allows you to get the current date as a DATE type like the SQL Standard's CURRENT_DATE feature. What is the <current date value function> for SQL Server?...
0
votes
1answer
95 views

Count days between dates and find largest gap

I need to find all members in our database from a calendar month that do not have a gap of 10+ days between sending data / or in the month total i.e. everyone in April 2018. The table is set up like ...
5
votes
1answer
296 views

Getting year DATEPART from Unix date

In my database, the dates are retained as days elapsed since/before 01/01/1970, which I understand to be a Unix date format, eg. today is 23rd May 2018 and the value is 17674. I'm trying to run a ...
1
vote
3answers
123 views

SELECTing data based on a specific time frame

I'm using PostgreSQL. I have a table which stores data related to some orders. It has four to five columns, including: cust_code char varying (20), sugg_order integer, ordered_qty integer, date date ...
0
votes
2answers
3k views

select records by a particular month wise in sql

I want to get the records for a month of January'2017 and here is the one row sample of my huge table Table: CUSTTRIPID TPTRIPID CUSTOMERID ENTRY_TOLLTXNID EXIT_TOLLTXNID ENTRYTRIPDATETIME ...
0
votes
1answer
27 views

What is the correct way to select data grouped by time interval?

I need to display a chart that would illustrate how many ticket sales happen at different time intervals on different dates, e.g. How many tickets for Friday show get sold 3 hours in advance, etc. ...
1
vote
1answer
90 views

Date and time period query

I would be very grateful if someone can help me here: in my database, I have prices recorded at a particular time in a day over years. So for each vendor or station, there can be several price data ...
1
vote
2answers
54 views

Find members with consecutive entries

I need to find all members in the database with data on 7 or more consecutive days. The table is set up as member_id and data_date. There are duplicate member_ids for each day that there is data. I ...
2
votes
1answer
55 views

Timezone considerations when choosing an appropriate datatype

We are currently developing a task management system for our bespoke application. After a lot of deliberation we came to the conclusion that we only need users to specify the due date for a task. I ...
0
votes
1answer
201 views

Current Date for Query

I have a query which I currently have to change the date in everytime. I would like to edit it so that it gives me all dates for the current month. Or is there a way to get it to request a date range. ...
0
votes
3answers
1k views

Select first and last rows between two dates MySQL

I have query: SELECT id, coins_id, first_coin, second_coin, price, `time` FROM hist_all WHERE `time` between (NOW() - interval 120 minute) AND NOW() AND (second_coin = 'USD' OR second_coin = 'USDT')...
3
votes
2answers
543 views

Get dates of the MSSQL Database Transaction Log records

I am wondering if there is a way not just to get the transaction log (e.g. using fn_dblog), but also get the date for the start of execution for each of the transactions recorded? It's okay to get ...
0
votes
1answer
92 views

Convert list of dates in a date range in SQL Server

Convert list of dates in a date range in SQL Server For ex:
1
vote
1answer
82 views

How to display all the dates in the date-range having group by dates?

Suppose I have a table called “products”: Productive product-name product-quantity created-date 111 ABC 10 1/10/2018 222 XYZ 20 ...
0
votes
2answers
97 views

Trying to limit stored procedure results based on date

I have the following stored procedure: ALTER PROCEDURE [dbo].[TW_spRPTAllReceiverInventory] @SiteId varchar(50), @ReceiverId int, @UserName varchar(50) AS BEGIN DECLARE @SQL varchar(8000), ...