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
0 answers

How to let MySQL NOW() function return the user time

I ran into a very tricky MySQL issue.. Our DB is using type DateTime for the updated_at column, and now is too late to change it back to TimeStamp. I'm thus trying to add a trigger to update this updated_at column on table changing. The following is…
SexyNerd
  • 1,084
  • 2
  • 12
  • 21
0
votes
1 answer

Incrementing the values in a field of datatype DATE in Oracle

How to Write an update statement to update date_column to datecolumn+1 for all the dates in that column? i have a column named date in my table and i want to increment all the dates by 1 day for all the records in the table. eg: 01/JAN/2014 to…
Anirudh
  • 37
  • 5
0
votes
1 answer

Get the latest date in SQL from text format

I'm trying to get the latest date from a csv file , the dates are stored in this form NOV 14 2010 FEB 1 2012 JUN 18 2014 and my query is like SELECT Max(date) from table I'm getting NOV 14 2010 any idea ?
Ateeq
  • 797
  • 2
  • 9
  • 27
0
votes
4 answers

Invalid date while formating using simple date format

I have a date String Mon Feb 8 00:00:00 UTC+0530 1954. I want to convert it into the format DD/MM/YYYY. The output is always 08/38/1954 or 09/39/1954. I have used the following code. SimpleDateFormat format = new SimpleDateFormat("MM/DD/YYYY",…
Vinod
  • 3
  • 5
0
votes
2 answers

Data type/Varchar error

I'm trying to insert in my database (SQL Server 2012) a date (dd/MM/yyyy) from a DateTimePicker. When I checked my database, the format has been saved like (yyyy/dd/MM), the problem is when I choose a day between 13 and the last day of the month, I…
0
votes
1 answer

Storing Date Time in an XML column - XML format vs SQL Format

I have a stored procedure, which has the parameters OrderID (bigint) and ApprovalDateTime(varchar(25)) The SP simply updates an XML column called UserDef with the following XML for a given OrderID: 01/01/2013…
FMFF
  • 1,652
  • 4
  • 32
  • 62
0
votes
3 answers

String to date in MS Access SQL statement gives type mismatch error

Currently doing a data migration from a Microsoft Access database to a Microsoft SQL Server database using C#. I am trying to create a query to pull data from the Access database and order by two columns: Surname and Date. The challenge is that Date…
Arantuath
  • 243
  • 2
  • 5
  • 14
0
votes
2 answers

Converting a date a string to java.sql.Date format

I'm having an issue while trying to insert a date into an SQL server using Java: //final String input = "20120823151034"; final String input = "06282013143533"; final DateFormat df = new SimpleDateFormat("MMddyyyyHHmmss"); final Calendar c =…
user2335416
  • 311
  • 2
  • 4
  • 11
0
votes
2 answers

Insert datetime to database

Date currentDateTime; java.sql.Date sql_currentDateTime; currentDateTime = getCurrentDateTime(); //Fri Jun 21 15:53:59 AZST 2013 sql_currentDateTime = new java.sql.Date(currentDateTime.getTime()); //2013-06-21 PreparedStatement insertStmt =…
kamal
  • 1,093
  • 6
  • 19
  • 34
0
votes
2 answers

MYSQL Seconds column for time

I have a seconds column and I need to display in some readable format. Table A Time 259200 select Time from Table A and I need to get : 3 days,00:00:00 I need to have no of days if > 24 hrs. I tried lots of way but I was not able to get the right…
user2111815
  • 151
  • 1
  • 2
  • 10
0
votes
3 answers

How to form a string with parts of dates in SQL Server

I have datetimes in a table, in this manner (two in each row in a table): Row 1: 2012-06-31 01:00:00 Row 2: 2012-06-31 02:00:00 Row 3: 2012-06-31 03:00:00 Row 4: 2012-06-31 04:00:00 ... And I want to get each hour as an interval, to get it from a…
Jk041
  • 934
  • 1
  • 15
  • 33
-1
votes
2 answers

Return past 3 appointment and next 3 appointments

I need to get the past 3 appointments and the next 3 appointments from a certain date. Each of these queries give the expected result. My problem is that I need the results together. I can't use UNION because I need to use ORDER BY in both queries.…
Huerita37
  • 11
  • 4
-1
votes
1 answer

How to extract day of week from timestamp

I am trying to extract the day of the week from a timestamp in SQL Server. I am specifically looking for the SQL Server equivalent syntax to EXTRACT. I want to count how many fields are in each day of the week. This is how I would do it on…
Rivky
  • 1
  • 1
-1
votes
1 answer

How to get rows in a table that start from a specific date and time in SQL?

In one of my SQL Server tables, I have te following…
Pine Code
  • 2,466
  • 3
  • 18
  • 43
-1
votes
1 answer

How to get the current month in SQL query?

I run this type of query every month and I have to change the month number manually for the current-running month. SELECT * FROM table_1 WHERE year = '[current month]' Is there any way I can automate this process through a query which can fit in…
Sayyam
  • 11
  • 1
1 2 3
11
12