logo
down
shadow

Why do I get a different date after converting an Access query to SQL Server?


Why do I get a different date after converting an Access query to SQL Server?

By : user2950022
Date : November 17 2020, 04:28 AM
help you fix your problem to @AaronBertrand, using his sql code from SQL Fiddle, i was able to accomplish what i needed.
Answer
code :
DATENAME(hour, dbo.[Net Weight Tracking].[Start Time])+':'+DATENAME(MI,[Net Weight Tracking].[Start Time]) AS StartTime,DATENAME(hour, dbo.[Net Weight Tracking].[Stop Time])+':'+DATENAME(MI,[Net Weight Tracking].[Stop Time]) AS StopTime, 
                       DATEPART(HH, dbo.[Net Weight Tracking].[Start Time]) AS HrStart, DATEPART(HH, dbo.[Net Weight Tracking].[Stop Time]) 
                      AS HrStop, DATEADD(MINUTE, DATEDIFF(MINUTE, 0, CONVERT(TIME, [Start Time])), [Date]) AS Start, CASE WHEN DATEPART(HH, dbo.[Net Weight Tracking].[Start Time])>12 AND DATEPART(HH, dbo.[Net Weight Tracking].[Stop Time])<12 THEN  (DATEADD(MINUTE, DATEDIFF(MINUTE, 0, CONVERT(TIME, [Stop Time])), [Date]) + 1)  ELSE DATEADD(MINUTE, DATEDIFF(MINUTE, 0, CONVERT(TIME, [Stop Time])), [Date]) END AS STOP


Share : facebook icon twitter icon
Converting from normal date to unix epoch date in MS Access SQL query

Converting from normal date to unix epoch date in MS Access SQL query


By : user2516370
Date : March 29 2020, 07:55 AM
help you fix your problem Don't know if this is going to work (don't have Access to confirm), but try the suggestion from here:
http://weblogs.sqlteam.com/jeffs/archive/2007/04/13/format-date-sql-server.aspx
code :
    DATEDIFF(second, '1 Jan 1970', tbl.LastChangeDate)
Error with converting access query to SQL Server 2012 query

Error with converting access query to SQL Server 2012 query


By : Amilgar Manuel Corts
Date : March 29 2020, 07:55 AM
I wish this helpful for you I am converting queries from Access 1010 into SQL Server 2012. The following is part of a query , You can do something like this....
code :
SELECT  TotalSessions
       ,TotalDuration
       ,Round([TotalDuration]/[TotalSessions],1) AS AverageDuration
FROM (
        SELECT  Count([Stats].SessionNumber) AS TotalSessions
               , SUM([Stats].Duration) AS TotalDuration
        FROM Table_Name
     ) A
Converting an Access Query with IIF to SQL Server

Converting an Access Query with IIF to SQL Server


By : Victor Marques
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I am looking for a bit of help converting an access query into sql server. , Try this
code :
AND 5 = CASE WHEN [if_submission].[submissiontypeid] = 8 
          THEN [payrollruns].[payemonth]
          ELSE [if_submission].[periodnumber]
        END
Converting SQL Server Date Format from Rails Query

Converting SQL Server Date Format from Rails Query


By : fabbrillo
Date : March 29 2020, 07:55 AM
seems to work fine Trying to complete the following query: , Why not make the change to what you are querying against instead?
code :
@articles = Article.where(created_at: DateTime.now.beginning_of_day..DateTime.now.end_of_day)
@articles = Article.("created_at >= ?", Date.today.beginning_of_day)
Converting Numeric date into date time in SQL Server query

Converting Numeric date into date time in SQL Server query


By : Traian Craciunescu
Date : March 29 2020, 07:55 AM
it helps some times The data is a number type. You have to cast it so a string type before you can use it with the substring function:
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org