sql-date-functions

SQL date format [h]:mm:ss like Excel does, beyond 24 hr

醉酒当歌 提交于 2019-12-11 06:44:16
问题 There is a translation for Excel built-in date format [h]: mm:ss in T-SQL or any SQL platform? example: General [h]:mm:ss [mm]:ss [ss] 1.00000 24:00:00 1440:00 86400 1.00000 24:00:00 1440:00 86400 SUM 2.00000 48:00:00 2880:00 172800 For T-SQL I will select Without century (yy) (1) With century (yyyy) Standard Input/Output (3) 14 114 - hh:mi:ss:mmm(24h) Or by default 108, I am discerning is do I have to recreate a function that can do the hh:mi:ss:mmm ( +24h )? Comments are very welcome; 回答1:

MySQL query to update records with incremented date

心不动则不痛 提交于 2019-12-09 23:43:44
问题 I am trying to get the latest date in a database, and based on that date update every record that has a NULL date, increasing the date by 1 day. I can get the latest date by using the Latest Date query below. I need to do this first because the dates in the table are not in order. If need be, I can run this query, manually write it down, then run the UPDATE query based on this date. I would prefer to run everything without the manual process. The last query I have at the bottom of the

Is there a function that takes a year, month and day to create a date in PostgreSQL?

雨燕双飞 提交于 2019-12-08 14:39:44
问题 In the docs I could only find a way to create a date from a string, e.g. DATE '2000-01-02' . This is utterly confusing and annoying. What I want instead is a function that takes three parameters, so I could do make_date(2000, 1, 2) and use integers instead of strings, and returns a date (not a string). Does PostgreSQL have such a built-in function? The reason I'm asking this is because I dislike the use of strings for things that are not strings. Dates are not strings; they're dates. The

Updating table with business day and calendar day

自作多情 提交于 2019-12-08 02:54:06
问题 I have a table in SQL Server 2012 that is updated manually every month to reflect what date is a file expected to come in. The date rule already has values but the expected date column is what is updated manually. If its expected on BD1(Business Day 1) I will update to the first non-weekend day of the month. If its expected on CD1(Calenday Day 1) I will update to the 1st regardless if it falls on a weekday or a weekend and so forth. Is it possible to write an update query where it would loop

Filter data based on date in sql

痴心易碎 提交于 2019-12-07 10:55:52
问题 Im trying to execute the following SQL query and filter out the data based on the date. I need to display a table which filters out the data such that, only those rows which are between the mentioned start_date and end_date Here's the query that I have been trying SELECT DISTINCT T1.column1, T1.column2, T2.START_DATE, T2.END_DATE FROM Table1 T1, Table2 T2 WHERE (T1.column1= T2.column2) AND (T2.START_DATE >= '15/01/2013 10:58:58' AND T2.END_DATE <= '18/01/2013 10:58:58') ORDER BY T2.START_DATE

Updating table with business day and calendar day

岁酱吖の 提交于 2019-12-06 06:31:06
I have a table in SQL Server 2012 that is updated manually every month to reflect what date is a file expected to come in. The date rule already has values but the expected date column is what is updated manually. If its expected on BD1(Business Day 1) I will update to the first non-weekend day of the month. If its expected on CD1(Calenday Day 1) I will update to the 1st regardless if it falls on a weekday or a weekend and so forth. Is it possible to write an update query where it would loop through the values and update automatically? I'm having trouble figuring out to update to the correct

Oracle date function for the previous month

你。 提交于 2019-12-05 15:21:49
问题 I have the query below where the date is hard-coded. My objective is to remove the harcoded date; the query should pull the data for the previous month when it runs. select count(distinct switch_id) from xx_new.xx_cti_call_details@appsread.prd.com where dealer_name = 'XXXX' and TRUNC(CREATION_DATE) BETWEEN '01-AUG-2012' AND '31-AUG-2012' Should I use sysdate-15 function for that? 回答1: Modifying Ben's query little bit, select count(distinct switch_id) from xx_new.xx_cti_call_details@appsread

Filter data based on date in sql

跟風遠走 提交于 2019-12-05 14:30:50
Im trying to execute the following SQL query and filter out the data based on the date. I need to display a table which filters out the data such that, only those rows which are between the mentioned start_date and end_date Here's the query that I have been trying SELECT DISTINCT T1.column1, T1.column2, T2.START_DATE, T2.END_DATE FROM Table1 T1, Table2 T2 WHERE (T1.column1= T2.column2) AND (T2.START_DATE >= '15/01/2013 10:58:58' AND T2.END_DATE <= '18/01/2013 10:58:58') ORDER BY T2.START_DATE DESC I get the result with values from 2012 as well. Please help me out Thanks Since you have not

MySQL query to update records with incremented date

≯℡__Kan透↙ 提交于 2019-12-04 19:30:59
I am trying to get the latest date in a database, and based on that date update every record that has a NULL date, increasing the date by 1 day. I can get the latest date by using the Latest Date query below. I need to do this first because the dates in the table are not in order. If need be, I can run this query, manually write it down, then run the UPDATE query based on this date. I would prefer to run everything without the manual process. The last query I have at the bottom of the question is my test query for trying to update the dates, however I had no luck getting it to work. Table

First day of the next month

孤者浪人 提交于 2019-12-04 16:37:26
问题 I'm trying get the results where it only displays OrderDates before the LAST day of the CURRENT month. I'm guessing it would be like this... SELECT OrderDate FROM Orders WHERE OrderDate < (code for first day of the next month?) 回答1: First day of next month: sql-server 2012+ DATEADD(d, 1, EOMONTH(current_timestamp)) sql-server 2008 and older: DATEADD(m, DATEDIFF(m, -1, current_timestamp), 0) 回答2: Your question is somewhat ambiguous, but this will give you '(code for the first day of the month)