Skip to main content
0 votes
2 answers
158 views

Dynamic Column alias based on a function in BigQuery

I am trying to alias a column based on a DateTime function in BigQuery. Below is my query snippet, SELECT SUM(CASE WHEN CAST(AsOfDate AS DATE) >= DATE_TRUNC(CURRENT_DATE,MONTH) ...
Jude92's user avatar
  • 167
0 votes
3 answers
61 views

SQL Time Intervals

RegistrationDate 2024-10-31 07:30:00.000 2024-10-31 07:50:00.000 2024-10-31 08:40:00.000 2024-10-31 09:30:00.000 2024-10-31 10:40:00.000 2024-10-31 11:30:00.000 2024-10-31 13:00:00.000 2024-10-31 13:...
S.exe's user avatar
  • 1
0 votes
1 answer
325 views

SQL query to get prior month in Athena

I want to get last month data (fist day of month through last day of month). My data is in UT (universal time) and need to pull in ET (July). I need to count the number or purchases (by counting the ...
Mar's user avatar
  • 1
1 vote
1 answer
60 views

Oracle - inserting date in a format not yielding input date format

I am using below insert statement to enter record in table submissions in which column submission_date of date data type: insert into submissions values (to_date('2016-03-01', 'yyyy-mm-dd'), 8494, ...
kritika pandey's user avatar
1 vote
1 answer
59 views

How do I find the date before a value changes in T-SQL?

So I have a following table: CreatedAt ID NewStatus OldStatus 2023-03-08 13:34:57.0000000 1645 Draft NULL 2023-03-22 19:58:51.0000000 1645 Active Draft 2023-...
brins's user avatar
  • 23
0 votes
2 answers
59 views

How to load last 7 days into a string(list)

I'm trying to create a program that watches and searches for any logs within given dates. How can I load the last 7 days in DATE format (YYYY-MM-DD) to a string/string list, or via SQL, or Qt/C++. ...
ifteapotsareforteawhatarepots4's user avatar
0 votes
1 answer
73 views

Convert Local Time {'09:58:00'} to UTC

I have a requirement to store Local time(10:31:00) to UTC(04:31:09) in the SQL Server. I have used the below query to get the desired result. I have combined @VitalReadingDate='2024-01-11' and local ...
ravi's user avatar
  • 17
0 votes
0 answers
813 views

Need an SQL query with YEAR and MONTH functions in SAP B1 using Service Layer

I'm having issues trying to apply a query in SAP B1 (HANA) through the service layer, so that it can be read from Power BI or Excel. The original query involves grouping costs by equipment, year, and ...
DeSyDo's user avatar
  • 53
0 votes
1 answer
41 views

Is there a way to call GROUP BY as a variable within a calculated field in sql?

i am trying to sort by the year as my calculated field is not correct when trying to graph by date. i think if i get the date to be in chronological order then my problem will be solved but i'm not ...
fi123's user avatar
  • 1
0 votes
3 answers
324 views

sql group by end of the week on Sundays

I have 3 columns in my table: bill_date (daily data), country, revenues How to group by country and get sum of revenues if I want to group my bill_date by the end of every week that fall on Sundays ? ...
Andreabic's user avatar
0 votes
2 answers
609 views

First day of the next year with rolling year in Oracle

I always need the 1st of the next year for a query in my Oracle. The date format from today's perspective should therefore look like this: 01-JAN-24 However, this year should adjust automatically as ...
Miko's user avatar
  • 506
0 votes
0 answers
138 views

TIMESTAMPADD() is giving me an operand error inside the where clause and I cant figure out why

I am using a version of SQL for Advantage Databases. In the below code, I am attempting to retrieve the total amount from the past year for each customer. However, the TIMESTAMPADD() WHERE function ...
Ratguy's user avatar
  • 3
1 vote
1 answer
136 views

SQL behaviour when using string literal vs using date literal

Suppose I have this two queries: SELECT * FROM payments WHERE created < DATE '1967-01-01' SELECT * FROM payments WHERE created < '1967-01-01' And created field is a date field. I would like to ...
Hey jude's user avatar
1 vote
0 answers
25 views

Why is there no consistency between how parameters are processed in DATEDIFF and TIMESTAMPDIFF in singlestore?

SELECT TIMESTAMPDIFF(DAY, '2014-12-04', '2014-12-05') as DAYS_DIFF returns 1 ,but SELECT DATEDIFF('2014-12-04', '2014-12-05') as DAYS_DIFF returns -1. Why does TIMESTAMPDIFF do date2-date1 whereas ...
Gopick's user avatar
  • 91
-1 votes
1 answer
84 views

Between conditions with dates has odd behavior

I have this T-SQL query in SSMS: DECLARE @TodaysDate datetime DECLARE @AsAtDate DATETIME SET @TodaysDate = GETDATE() PRINT (DATEPART(WEEKDAY, @TodaysDate)) IF DATEPART(WEEKDAY, @TodaysDate) = 2 ...
Prosy A.'s user avatar
  • 2,820

15 30 50 per page
1
2 3 4 5
20