I am trying to figure out how MS access calculates the following query where contractualDate and ContractualTime are both datetime:
(Max(([contractualDate]+[ContractualTime]))-Min(([contractualDate]+[ContractualTime])))*25,0) AS TrailerCost
The closest I could think of using SQL is
Datediff(m,Min(([contractualDate]+[ContractualTime])),Max(([contractualDate]+[ContractualTime])))*25 AS TrailerCost
This gives me results that differ from the first VBA code, what did I do wrong here?
Related
Facing very strange issue regarding PL/SQL function call from VBA and Output of same on Oracle SQL Developer. Both seems to vary by a lot. Please go through the attached screen shots. 1st Image shows the VBA output.
Here is the output which I get on ORACLE SQL Developer
More strange thing here is, This error I am facing only for few FSYM_IDs not all. For others its coming very much precise.
I did see the following question
Similar Question
There user had mentioned about hash joins but I haven't used any sort of hash joins at all.
I have used ADO and Range.CopyFromRecordSet to fetch data into excel. Executed the same exact query which is
select FSYM_ID, CURRENT_FY, ROUND(VALUATION_PB_HIGH,0), ROUND(VALUATION_PB_LOW,0) from table(PRICE2BV('07BR8Q-R'))
into excel and oracle sql developer.
I have updated the SQL Developer screenshot. Difference is in the particular years high and low value. I have highlighted that in the SQL developer output.
Additional things about Oracle PL/SQL functions are
Function returns data from global temporary table.
Variables used are of type number or varchar only.
Input to the function is identifier for the company only.
I have tried to retrieve output using table also but no use.
I have even tried the approach of GetRows mentioned on following link.
SQL Query output in VBA is different than in SQL Oracle
One thing I observed regarding recordset is that==> Values are different when I query from VBA and Oracle SQL Developer.
Please help me regarding same.
I have tried to make a calculated field in a query with the build tool
EindDatum: DateAdd("yyyy",1,[tblVERHURING]![DatumVerhuring])
I get an error
The expression you entered contains invalid syntax
If I use the SQL tool and type the following, I get the result I want
SELECT DATEADD("yyyy", 1, [tblVERHURING]![DatumVerhuring]) AS EindDatum
FROM tblVerhuring;
My question: is it possible to build this SQL expression with the build tool, and what should the code be?
you probably need to change the yyyy for your language.
Maybe this will help you:
EindDatum: DateAdd("jjjj",1,[tblVERHURING]![DatumVerhuring])
This works for Dutch versions of MS Access
see the related docs
I'm trying to connect one database to excel.
When the table its linked without any conditions with works perfectly.
When I'm trying to put a WHERE condition I got the type mismatch error.
Where Data.`InfoCreation Date`>= ?
On access the field is using date/time for Data type and it looks like:
InfoCreation Date
18/12/2018 05:49:00
And I am trying to match in excel with a date format type like: 18/12/2018
What I want to have is to select all the dates before one choosed day.
Can someone help me with this?
Thanks
You would need to convert your string to a date. For that you can use the msaccess FORMAT() function
Data.`InfoCreation Date`>= Format(?, "dd/mm/yyyy")
A timeclock table in SQL is storing TimeIn/TimeOut as 1:00p in a format which when i export into excel will not let me subtract and get the time difference.
I was trying to run a query in SQL and convert the times within SQL so that when i export i can subtract. In Access i was using CVDate.
This is the sql code i tried using:
Convert (varchar(6), dbo.tblPayrollFlashPunch.TIME_IN, 108) as TimeIn,
CONVERT (varchar(6), dbo.tblPayrollFlashPunch.TIME_OUT, 108) as TimeOut,
Any help will be appreciated, btw I am very new to SQL and we are running SQL 2008.
Below is a snapshot of sample data.
(Original here: http://i.stack.imgur.com/AS8BS.gif )
Edit: I was hoping SQL could do the conversion so that i could pull the data through a view directly into excel and have the correct format so that my formulas work. Also, I've tried changing the formats in excel with no success. In MSAccess you can use CVDATE and works great.
Edit 2: Being the noob that I am i just realized we are running SQL Server 2005 which explains why i cant use many of the suggested functions.
Which SQL are you using?
In T-SQL, I believe this would work if your time column is a string/varchar.
CONVERT(TIME, (dbo.tblPayrollFlashPunch.TIME_OUT + 'm'), 108) as TimeOut
What about using DATEDIFF in TSQL to get the difference straight from there?
I am new to VB.net & SQL server 2008 and I am trying to get the Total Worked hours (Sum) in SQL report which is datatype is smalldatetime and I tried the below codes which already posted in a previously asked question. The my problem is the first method is giving me an #error and the second method is giving me wrong calculation. If anyone can help me with this I am really grateful.
1st Method which gave me an #error as below
=TimeSpan.FromTicks(Sum(Fields!TheTime.Value))
2nd method Which gave me wrong calculation as below
=Date.FromOADate(Sum(Fields!TheTime.Value.ToOADate())).ToString("hh:mm:ss")