Questions tagged [sqldatetime]

The SQLDateTime tag is for questions related to how database SQL queries handle date and time information.

Databases can store date and time information in various ways. The is used for questions related to defining and accessing date/time data. Some considerations for this type of data are

  • Precision
  • Calculations
  • Business rules
  • Scheduling

Most database software allows date types that include both the date and time of day. There are various types of date types that can include timezone information, and interval information.

See the for questions relating to functions used for determining things such as last_day(date) which returns the last day of the month for the specified date, and functions for returning the current date or timestamp.

177 questions
0
votes
1 answer

Modifying a query to work without requiring NLS_DATE_FORMAT to be set

I the following query: SELECT trunc(estimatedenddate,'hh') AS reg_date, COUNT(*) FROM ( SELECT attr_value, TO_DATE( (DATE '1970-01-01' + (1 / 24 / 60 / 60 / 1000) * attr_value),'yyyy-mm-dd HH24:mi:ss') AS…
Saqib Ali
  • 3,953
  • 10
  • 55
  • 100
0
votes
2 answers

What should be an 'expiration date' column type when in some cases it doesn't have any value? (blank? null? 0000-00-00?)

I have a table stating which items I am using in my main menu: model | display_name | sub_menu | active MYSQL: CREATE TABLE `main_menu` ( `model` varchar(255) NOT NULL COMMENT 'name of the model', `display_name` varchar(255) NOT NULL, …
Imnotapotato
  • 5,308
  • 13
  • 80
  • 147
0
votes
0 answers

Delete from Mysql table where datetime is older than datetime of another item

I have some difficulty to get my MySQL query right. The current status is like this: I have a table containing Todo's with a datetime field changed_at (set to current datetime on insert/update) I want to build a query that checks on…
0
votes
1 answer

Mysql read string as datetime

Hello I'm using LOAD DATA INFILE to populate a table in MySQL. LOAD DATA INFILE 'test.txt' INTO TABLE myTestTable FIELDS TERMINATED BY '\t' IGNORE 1 LINES; Everything is working peachy except that there is a datetime column in my data that is…
sameagol
  • 613
  • 1
  • 8
  • 16
0
votes
1 answer

why does Timestamp print difference between run model and debug model in unit test?

java.sql.Date date = java.sql.Date.valueOf("1900-01-01"); //-2209017600000 System.out.println(date.getTime()); java.sql.Timestamp timestamp = new Timestamp(date.getTime()); System.out.println(timestamp); if directly running in…
Haven Lin
  • 176
  • 1
  • 16
0
votes
2 answers

Derive a new column based on Time stamp

I have a column 'customer_date' with datatype text. Based on the time i need to derive a new column Condition : when customer_date <12 then 'AM' else 'PM customer_date 01Mar2018 10:03:54 02Mar2018 13:03:54 expected output customer_date …
user8545255
  • 761
  • 3
  • 9
  • 21
0
votes
1 answer

How to add currentdatetime when data inserted on table

I got these errors on my script error log iam using php version 5.3 and this is my code : // add entry $sql = "INSERT INTO plugin_reward_ppd_detail (reward_user_id, download_ip, file_id, download_country_group_id, download_date,…
nagy00
  • 7
0
votes
1 answer

Why Does SQL Query of >= '5/1/2018' and <= '5/1/2018' only return rows of 2018-05-01 00:00:00?

Ok I should know this after 20+ years of coding and querying databases, but it still doesn't make sense to me. If I do this: SELECT * FROM sometable WHERE createdate >= '5/1/2018' and createdate <= '5/1/2018' I get: 6500061 2018-05-01…
Indy-Jones
  • 668
  • 1
  • 7
  • 19
0
votes
0 answers

convert many date formats to its assigned formatted date

I want to convert Non-Standard Date Formats to Standard Date format. Table has Column_A and Column_B I have column_A as input and I want the corresponding value on column_B.
0
votes
0 answers

Arithmetic overflow error converting expression to data type datetime when running dynamic sql

I have seen a couple solutions to this SQL error(8115) but none seems to work for me. I think its because I am using dynamic SQL script. I dynamically pull data from multiple servers that have the same structure and insert into a central table. The…
Castell James
  • 329
  • 6
  • 23
0
votes
1 answer

MariaDB View not working but statement does

My new hosting provider is running MySQL Version 10.0.31-MariaDB-cll-lve I have a view that was working fine in MySQL 5.6 but does not work in MariaDB. I have created a simple cut down version just to show what is causing an error. I can create the…
Craig
  • 2,093
  • 3
  • 28
  • 43
0
votes
1 answer

How to get Last Month interval with MSSQL in January

How can this code be fixed, so it doesn't break in January? I believe this part is the bug: (Month(Getdate()) - 1 SQL: AND UOnline.maxstamp > dbo.Udf_converttotimeinterval( Cast(Cast(Year(Getdate()) AS VARCHAR(4)) …
radbyx
  • 9,352
  • 21
  • 84
  • 127
0
votes
1 answer

Finding DataSet DateTime value using C# DateTime input in .net 3.5 (mobile)

For reasons beyond my control, I find myself using .net mobile 3.5. I need to be able to use the Rows.Find(Object) function on a DataTable where the Primary Key is a DateTime. Ex: DataRow temp = exDataSet.exDataTable.Rows.Find(exDateTime); I have…
0
votes
2 answers

Date won't change after using DATEADD() function in SQL Server 2017

I have a date stored in a string (@cnp=1051597991234) the date being 051597 representing 5/15/1997. I am using the following code to set a date variable with the needed value, in the end to compute the current age. I used the debugger but somehow it…
rednefed
  • 71
  • 2
  • 11
0
votes
0 answers

MySQL datetime and timestamp only showing date (without time) when called on a query in Java

I created the following table on a MySQL DataBase: CREATE TABLE DATES( DT DATETIME, TS TIMESTAMP, ); And inserted the following data into the DATES: INSERT INTO DATES(DT, TS) VALUES(NOW(), NOW()); So when I do the following query: SELECT…
AC Zepp
  • 1
  • 1