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
2
votes
4 answers

String date to java sql date conversion

i need to format this String date Tue Sep 23 14:36:59 PKT 2014 to java sql date but i need both date and time, i tried this String st = "Tue Sep 23 14:36:59 PKT 2014"; new java.sql.Date(new SimpleDateFormat("EEE MMM dd hh:mm:ss zzz…
NoNaMe
  • 6,020
  • 30
  • 82
  • 110
2
votes
2 answers

Inconsistent SQLDateTime Overflow with NHibernate

We have a very strange error that sometimes we get this error when we want to save something from our WCF service. The object that we are saving contains NO invalid datetimes, we all check them before we save. When we see this error the database…
Sven
  • 371
  • 1
  • 6
  • 17
2
votes
1 answer

How to use GETDATE() in Oracle to find number of days between Current Date and some specified date?

Suppose I have a table called projects and it has columns as projectid, startdate and enddate. The startdate of each project is specified already and the enddate is specified only for projects that are already finished. For ongoing projects, the…
ronilp
  • 455
  • 2
  • 9
  • 25
2
votes
1 answer

SqlDateTime overflow using NHibernate

I persist my objects using NHibernate in the database the App object have a property defined: public virtual DateTime ReleaseDate { get; set; } in the mappingClass: Map(x => x.ReleaseDate).Not.Nullable(); which in the sqlServer 2008 its dataType…
2
votes
1 answer

How to convert time which is in GPS format to Local time format in SQL?

This is the data packet which was received from android mobile to my server. $|351746051743568|12.9399604|77.6257631|0.0|1392979784822|1|# In which following is the time which is received from the device: 1392979784822. Since this is in GPS…
Rameshbabu
  • 57
  • 8
2
votes
1 answer

Why does date type hugely affect performance of query execution?

I have the query of the following form: DECLARE @date DATETIME = SELECT .... FROM a WHERE AND a.LastEvent < @date LastEvent column is of type DATE. Query works pretty fast. But if I change @date type to DATE query…
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
2
votes
5 answers

How to update multiple columns based on values from an associated table?

There are two tables named masters and versions. The versions table holds entries of the master table at different points in time. ------------------------- masters ------------------------- id | name | added_at ----+-------+------------ 1 |…
JJD
  • 50,076
  • 60
  • 203
  • 339
2
votes
1 answer

Pass DateTime2 parameter value using ISqlQuery

I am using the ISqlQuery interface of Nhibernate to fire a SQL query on database. Following is the scenario. My Domain Model has a property: public virtual Datetime StartTime { get; set; } The database has a column StartTime of type DateTime2. I…
Niraj
  • 376
  • 4
  • 14
1
vote
4 answers

Split column, and then convert different date types to standard date format (YYYY-MM-DD) - SQL Server

I have requirement to split column in 2 separate columns and then convert multiple date types column to standard date format column. CREATE TABLE Report (Id INT, Reference VARCHAR(30)); INSERT INTO Report VALUES (1, 'Location (11/8/22)'), (2,…
Yara1994
  • 317
  • 2
  • 11
1
vote
1 answer

Get dates for last 30 days dynamically in SQL

I have below SQL which gives me count of files received in particular country according to date. But here dates are hard coded. I want them dynamically. I want it in such a way that whenever I run this query, I get result for last 30 days. Below is…
AKHIL OMAR
  • 47
  • 6
1
vote
1 answer

Improving group by query for large time-series dataset

I have a large table with time-series data for a whole year, with 24 values for each day (one per hour), for multiple customers. Customer-ID Date Value 001 2020-01-01 00:00:00 xx 001 2020-01-01 00:01:00 xx 001 2020-01-01…
HealYouDown
  • 158
  • 3
  • 12
1
vote
3 answers

SQL query for CASE WHEN 2 dates match

New to SQL so sorry if this is a basic question. Looking to create a column that indicates a match in two dates (i.e. the date the record is created is identical to the date the record is expired). My two date variables are timestamps in the format…
DrPaulVella
  • 391
  • 8
  • 22
1
vote
1 answer

Is there a way to acess previous specific value in SQL?

I am working in Oracle live SQL with this same table with data for the whole year (in which the intervals can be larger). This is just an example(part of the whole table): I have to add two columns that will show the interval the dates are in(based…
1
vote
1 answer

Creating date table from dual

I have been trying to figure out how to create a table out of this code, but can not figure it out. Thank You so much for any answers. WITH dat_param AS (SELECT SYSDATE AS dat FROM dual) SELECT LEVEL AS day_year ,TRUNC((SELECT dat FROM…
1
vote
1 answer

How to fetch records based on from and end time in mysql

I am facing one problem for fetching records from table. My table look likes below:- id market_id opening_time closing_time day p_slot 1 1 06:30:00 09:30:00 Friday 1 2 1 …
kunal
  • 125
  • 1
  • 8
1 2
3
11 12