473,750 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert Access Function to SQL

I'm going crazy trying to convert an Access Function to SQL.
From what I've read, it has to be done as a stored procedure.
I'm trying to take a field that is "minutes.second s" and convert it to minutes.

This is what I have in Access:

Function ConvertToTime (myAnswer As Variant)
Dim myMinutes
myMinutes-(((((myAnswer * 100)Mod 100/100/0.6)+(CInt(myAn swer-0.4))))
ConvertToTime =(myMinutes)
End Function

When I tried to modify it in SQL:

CREATE PROCEDURE [OWNER].[PROCEDURE NAME] AS ConvertToTime
Function ConvertToTime(m yAnswer As Variant)
Dim myMinutes
myMinutes = (((((myAnswer * 100)Mod 100)/100/0.6)+9CInt(myAn swer-0.4))))
ConvertToTime=( myMinutes)
End

I get an error after ConverToTime.
Jul 20 '05 #1
2 5015
Transact-SQL is not VB!

If you are using SQL2000 you can create a user-defined function:

CREATE FUNCTION dbo.ConvertToMi nutes (@minsec DECIMAL(5,2))
RETURNS DECIMAL(5,2)
BEGIN
RETURN ROUND(@minsec,0 ,1)+(@minsec-ROUND(@minsec,0 ,1))*10/6
END

GO

SELECT dbo.ConvertToMi nutes(100.30)

Result:

-------
-100.50

(1 row(s) affected)

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 20 '05 #2
Mich wrote:

CREATE PROCEDURE [OWNER].[PROCEDURE NAME] AS ConvertToTime
Function ConvertToTime(m yAnswer As Variant)
Dim myMinutes
myMinutes = (((((myAnswer * 100)Mod 100)/100/0.6)+9CInt(myAn swer-0.4))))
ConvertToTime=( myMinutes)
End

T-SQL uses "Return <value>" for functions, like C or Java, not
"<Function Name> = <value>", like VB (including Access) or Pascal.

Bill

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
26301
by: SD | last post by:
Hi, This is driving me nuts, I have a table that stores notes regarding an operation in an IMAGE data type field in MS SQL Server 2000. I can read and write no problem using Access using the StrConv function and I can Update the field correctly in T-SQL using: DECLARE @ptrval varbinary(16) SELECT @ptrval = TEXTPTR(BITS_data)
1
7698
by: Gary Dale | last post by:
I have a database that was originally set up in Access 97 (because that was what we had in the office). We had a copy of Access 2000 set up on one machine for a brief period to get at another database that required it. Unfortunately someone used that machine and "upgraded" the Access 97 database to Access 2000. Now I'm trying to get it back to Access 97 but the "convert to prior version" function keeps telling me that it can't convert...
2
15863
by: Bubba | last post by:
I know it's possible, just don't know how to do it. I have a spreadsheet that I imported into access. Two of the columns in the table have Hard Drive space values listed for example 2.45 GB and 453 MB, you get the picture. Both the GB and MB assorted values exist in both columns. Is there anyway to convert the GB or MB to 0's, or even better yet decimal places so I can look for values < or > to 6gb. I already tried a query, but it seems...
3
7226
by: Derek Riley | last post by:
I have been using Access97 for some time now and decided to upgrade to 2000, the problem is when I convert it to 2000 I get the following message "There were compilation errors during the conversion" it looks like it is due to the DAO 2.5/3.5 reference. Is there a conversion utility that I can run to convert it to DAO 3.6 to run in Access 2000 There seems to be a lot of changes required in the module where it is using
12
2213
by: dixie | last post by:
Can someone familiar with Access 2003 please answer this question? I am asking because I don't have the use of A2003. When Access 2003 finds an Access 2000 database, does it come up with some sort of question/suggestion indicating that you can convert this datbase into the new format? I am trying to trouble shoot a remote site where a big error message indicating the database was converted using the wrong method comes up when they try to...
2
16217
by: Phil Stanton | last post by:
When designing a new form or report, the Default ForeColor is often something like -2147483640 which is the colour of Windows text (possibly black) and the default backColor is -2147483643 (possibly white) Can anyone tell me how to convert these colours to either RGB colours or the Long number used by Access. Black is 0 and White is 16777215 ...
9
73871
by: photomonkey | last post by:
I am having a problem with a relatively simple sql query, and was hoping that somebody could help me on this forum. Basicaly the situation is that I have two tables, a Vendors table (Vendors) and a ProductCatalogue table (ProdCat). I wish to select the VendorID, and VendorName from the vendors table. Additionally I want to run a subquery on (SELECT COUNT(*) FROM ProdCat WHERE ProdCat.Pcat_VendID=Vendors.Vend_ID). I want to concatenate...
3
2704
by: ET | last post by:
I don't know whats the problem, but after I added functions to first verify, then relink linked tables if not found, now I can't convert that database to MDE format. I can split the database, but can't convert part of the database with forms, reports, queries to MDE format. Can somebody advice on this? References, in the order, from the top:
3
7991
by: Ursula | last post by:
Is it possible to convert a string in a file. The problem is this: I have an object string that is a file xml and I want to pass to Deserialize function, but Deserialize function expect an object of FileStream type and the mode access. There is a function Convert.ChangeType(object value, Type conversionType), but I cant write for example: Convert.ChangeType(mystring, FileStream); CAN YOU HELP ME????? thanks
0
8833
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2794
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.