Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8849219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:35:38+00:00 2026-06-14T12:35:38+00:00

Hi is there a function on SQL Server that can identify if Daylight Saving

  • 0

Hi is there a function on SQL Server that can identify if Daylight Saving Time is active or not.

where i created a scalar function that converts the server time to plant location time who uses the application upon insert/update is executed.

the problem is i did not know that there is DST on US. So my plan is i will do something like

if DST is active
   // -1
else
  // + 1
end

where i need to check if DST is active or not

Any ideas anyone?

Thanks and Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:35:40+00:00Added an answer on June 14, 2026 at 12:35 pm

    Handling Daylight time Function:

    CREATE function [dbo].[fn_GetDaylightSavingsTimeStart]
    (@Year varchar(4))
    RETURNS smalldatetime
    as
    begin
    declare @DTSStartWeek smalldatetime, @DTSEndWeek smalldatetime
    set @DTSStartWeek = '03/01/' + convert(varchar,@Year)
    return case datepart(dw,@DTSStartWeek)
    when 1 then
    dateadd(hour,170,@DTSStartWeek)
    when 2 then
    dateadd(hour,314,@DTSStartWeek)
    when 3 then
    dateadd(hour,290,@DTSStartWeek)
    when 4 then
    dateadd(hour,266,@DTSStartWeek)
    when 5 then
    dateadd(hour,242,@DTSStartWeek)
    when 6 then
    dateadd(hour,218,@DTSStartWeek)
    when 7 then
    dateadd(hour,194,@DTSStartWeek)
    end
    end
    
    CREATE function [dbo].[fn_GetDaylightSavingsTimeEnd]
    (@Year varchar(4))
    RETURNS smalldatetime
    as
    begin
    declare @DTSEndWeek smalldatetime
    set @DTSEndWeek = '11/01/' + convert(varchar,@Year)
    return case datepart(dw,dateadd(week,1,@DTSEndWeek))
    when 1 then
    dateadd(hour,2,@DTSEndWeek)
    when 2 then
    dateadd(hour,146,@DTSEndWeek)
    when 3 then
    dateadd(hour,122,@DTSEndWeek)
    when 4 then
    dateadd(hour,98,@DTSEndWeek)
    when 5 then
    dateadd(hour,74,@DTSEndWeek)
    when 6 then
    dateadd(hour,50,@DTSEndWeek)
    when 7 then
    dateadd(hour,26,@DTSEndWeek)
    end
    end
    
    declare @DLSStart smalldatetime
    , @DLSEnd smalldatetime
    , @DLSActive tinyint
    set @DLSStart = (select MSSQLTIPS.dbo.fn_GetDaylightSavingsTimeStart(convert(varchar,datepart(year,getdate()))))
    set @DLSEnd = (select MSSQLTIPS.dbo.fn_GetDaylightSavingsTimeEnd(convert(varchar,datepart(year,getdate()))))    
    if @Date between @DLSStart and @DLSEnd
    begin
    set @DLSActive = 1
    end
    else
    begin
    set @DLSActive = 0
    end
    select @DLSActive 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there MS SQL Server function that counts the number of times a particular
In sql-server there is function to auto-increment guid fields. CREATEGUID() how can I do
I am looking for a SQL Server function that I can supply 3 primary
is there any function in sql server 2008 that do the below job :
Are there any Linear Regression Function in SQL Server 2005/2008, similar to the the
Is there a function that can truncate or round a Double? At one point
i know there is a variable, function, or stored procedure that you can use
Is there a database level function (trigger or something) that I can use to
Possible Duplicate: Is there a way to create a SQL Server function to “join”
In SQL Server, you can apply the use function to point a query to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.