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
-1
votes
1 answer

How to do less than equal to for date in sqlite

When I try to run the below query I get no result even though the date time is same as that in the table. The BillDateTime column is of TEXT Data type SELECT * FROM BillingTransaction WHERE BillDateTime <= datetime('2021-09-19…
kumar
  • 8,207
  • 20
  • 85
  • 176
-1
votes
1 answer

PURE SQL get days beteen given date and current date, without functions

I need to get number of days between 2 dates, a given one and current date. But in pure SQL, I mean without usign functions, it is possible? For exaple SELECT days (t.givenDate) - days (current date) FROM table t Have you any idea? Thaks a lot.
Csanchez
  • 373
  • 1
  • 16
-1
votes
1 answer

Composing Big Query in App Script

I want to compose bigquery in app script with date1 & date2 variable (as mentioned below). What is the format to pass these 2 variable? var date1="20180601" var date2="20180606" var sql = "select * from table_query([project-name:dataset], 'table_id…
-1
votes
1 answer

Mysql select query between dates takes more execution time

In my test table there are 1 million rows, column id is auto generated number from 1 to one million and id column is unique index, timestore column storing insertion time, when execute select query between id range Ex: select * from test where id >…
-2
votes
4 answers

Get Last and Next Appointments

I have the following table in SQL Server and would like to get the last and next appointments for each customer. Note: If the first appointment is in the future, last appointment should be N/A. Similarly if the last appointment is in the past, next…
-2
votes
2 answers

Split date range into new records in Snowflake View

I have a table that consists of start and end dates and I need to need split records into day-wise and this needs to go in a View. | PersonID | CompanyID | Start_DT | End_DT | |-----------|--------------|-------------|-----------| | A12 …
-2
votes
5 answers

How do I subtract two datetime values?

I have a table with two columns login and logout. If a row has values "2019-08-07 20:37:12" in login column and "2019-08-07 21:14:16" in logout column, I want the difference between time values from login and logout columns. I have: SELECT…
-2
votes
2 answers

2017-01-01 00:08:57.231 format equals yyyy-MM-dd.HH:mm:ss?

I'm a bit baffled what format these timestamps are in. I was told the format to use is yyyy-MM-dd.HH:mm:ss but all of the timestamps appear like this 2017-01-01 00:08:57.231, 2017-01-01 07:43:36.348, or 2017-01-01 13:25:55.683. I'm not understanding…
Kyle Bridenstine
  • 6,055
  • 11
  • 62
  • 100
-2
votes
4 answers

SqlDateTime overflow exception (yyyy-mm-dd to sqldatetime)

I'm extracting a date-formatted string (yyyy-MM-dd) and then converting it to a DateTime and inserting it in the database using a storedprocedure. But I keep getting System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between…
user1021726
  • 638
  • 10
  • 23
-2
votes
4 answers

Is it possible to insert null(" ") value to the datetime field in the database

I have two fields DOB(date of birth) and (date of joining) If user enter the date then in the database insert->date else insert->null I have define properties as public DateTime DOB { get; set; } public DateTime DOJ …
Pritesh
  • 63
  • 1
  • 3
  • 11
-3
votes
1 answer

how to convert month date in a text column into datetime

I have a table containing two columns like this: Month_Date Year Dec 31 2018 May 01 2020 Jun 05 2021 Jan 18 2022 Jul 19 2019 I hope to combine the Month_date and year in the same row and put it in a new column as a…
-4
votes
3 answers

how can i format the java.sql.Date to MM/dd/yyyy

my code is final long MILLIS_IN_A_DAY = 1000*60*60*24; Date yesterdaydate= new java.sql.Date(new java.util.Date().getTime() - MILLIS_IN_A_DAY); out.println(yesterdaydate); the output am getting is in format yyyy/mm/dd..how can i get it in…
halfe
  • 85
  • 1
  • 2
  • 9
1 2 3
11
12