Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
1 answer
56 views

Query between two dates gives incorrect results in SQL Server? [closed]

Im trying: SELECT * FROM database a WHERE Applicant_End_date >= '2024-01-01' AND Applicant_Start_date <= '2024-06-30'; Results: Applicant_End_date shows results starting at 2024-01-01 like: ...
SirCal's user avatar
  • 1
0 votes
0 answers
160 views

Calculate Week Number of Year in T-SQL without DATEFIRST function or other database objects

I am working on a SaaS application that connects to a Microsoft SQL Server database, using T-SQL language. I cannot develop stored procedures, user-defined functions, or any database objects. I am ...
user3812887's user avatar
-1 votes
2 answers
49 views

SQL Date within range to give result [duplicate]

I'm looking to get a code that'll help me get a result from a date range based on a date. Table A D.O.B 1994-04-12 1996-12-06 2009-11-22 Table B DATE RANGE COLUMN Start cut off 1990-01-01 1999-12-...
NEWAgentSQL's user avatar
1 vote
1 answer
98 views

Make DATEDIFF() compatible with clock changes

In the UK, as part of daylight time savings, the clocks go forward by one hour at 1AM on the last Sunday in March which in 2024 was the 31st March The clocks effectively tick as follows: 2024-03-31T00:...
SE1986's user avatar
  • 2,700
1 vote
1 answer
89 views

Find the distinct closest date match for each record from 2 tables

Suppose I have Table1 and Table2 with the below data. I want to find the next closest Date match for Table 1(JoiningDt) that is available in Table2.ClosestDt for each ID. Note: Closest Match from ...
Poorna Prakash's user avatar
0 votes
1 answer
51 views

List premises & accounts within time period

I need to pull data from our MS SQL Server database regarding Premises (i.e. houses) and the accounts (i.e. people) that have live there (or are still living there) and their service period at that ...
Damon Combs's user avatar
0 votes
0 answers
60 views

SSIS Date Format Handling

I am seeking for suggestions of the date data handling. I have the following data in the date column from an excel file, it could be string, or date in different format. I wonder what's the best way ...
DataRookie's user avatar
0 votes
1 answer
99 views

Join tables by date ON less than or equal

I want to calculate users' profits based on their daily balance. Sample data per user: (vTnxDaily) DateOfDay Balance 2024-02-20 $250 2024-02-12 $80 2024-02-01 $420 Expected output: DateOfDay ...
Raeisi's user avatar
  • 2,091
0 votes
1 answer
400 views

How to select date columns from every table in the database?

I'm trying to select the minimum date from every date column inside my database. What I mean with minimum is that I want to obtain the earliest date. From what I've been investigating, it seems that ...
Luxia80's user avatar
  • 15
0 votes
0 answers
75 views

Get number of new sales based on previous month

Assuming Table A has an Area_Key, Date_Sold, and a Sale_ID, Here is what my query looks like to calculate # of Monthly Sales SELECT a.AreaKey, dbo.BOMONTH(a.[DateSold]) [Period], COUNT(a....
scarp's user avatar
  • 3
0 votes
1 answer
102 views

Create a column in SQL that shows if specific month is between two dates

I want to add a column to the results, for every month. The column should contain true if it is between two dates (dates come from the same row). For example I have date from = 2023-01-01 and date to =...
aksent1344's user avatar
0 votes
0 answers
62 views

How rounding on DATEDIFF in Millisecond works? [duplicate]

I am using SQL Server 2022 Microsoft SQL Server 2022 (RTM-CU8-GDR) (KB5029503) - 16.0.4080.1 (X64) Sep 1 2023 09:38:16 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit)...
ardikapras's user avatar
1 vote
0 answers
65 views

Moving Records based on Type, Confirmation Date, Type Table Hours Offset and working Calendar Date

I have been attempting to automate my Order movement process in SQL Server 2014 by having it look for these criteria; Order Type (Green, Blue, Purple) Confirmation Date (FIRST Date that a ...
Gary A MacDonald's user avatar
1 vote
2 answers
2k views

Convert datetime to date format

I am working on dates in a query and am seeing some unexpected behavior. I want to convert a datetime to dd-mm-yyyy format but seem to be unable to get the right result. On my Dutch machine I have the ...
Eseosa Omoregie's user avatar
1 vote
1 answer
72 views

Trying to clean date column but having difficulty; ending up with calculated column error

I have a dataset and I a particular column 'Last_DCR_Date' is in 'varchar' data type format, and my goal is to convert it to DATE format, but so far I've not been able to. An example of the data in ...
Bori's user avatar
  • 13

15 30 50 per page
1
2 3 4 5
196