Hi,
Sometimes I find it handy to construct an sql string for action queries, and
then run it directly against the database and/or connection instead of using
Recordsets for simple updates.
eg. This query works in MS Access (using dbs.Execute):
UPDATE Customer SET LastContact = #2/5/2005 13:15:00#
WHERE Customer.Custom erID = 101;
I'm now upsizing an app to SQL server, using ADP front-end.
Date/Time fields were converted (by the wizard) to MSSQL datetime fields.
I'm finding that Date/Time literal expressions (formatted as #m/d/yyyy
hh:nn:ss#) are not acceptible to MSSQL? Running above using cnn.Execute
gives SQL syntax error at the # symbol.
If so, how do you write a literal date in an SQL query for executing against
SQL server?
Thanks,
Ian. 2 13965
On Sat, 15 Oct 2005 03:18:58 GMT, "Ian Hinson"
<pp******@bigpo nd.net.au> wrote:
In T-SQL, dates are wrapped in single quotes.
-Tom. Hi,
Sometimes I find it handy to construct an sql string for action queries, and then run it directly against the database and/or connection instead of using Recordsets for simple updates. eg. This query works in MS Access (using dbs.Execute):
UPDATE Customer SET LastContact = #2/5/2005 13:15:00# WHERE Customer.Custom erID = 101;
I'm now upsizing an app to SQL server, using ADP front-end. Date/Time fields were converted (by the wizard) to MSSQL datetime fields.
I'm finding that Date/Time literal expressions (formatted as #m/d/yyyy hh:nn:ss#) are not acceptible to MSSQL? Running above using cnn.Execute gives SQL syntax error at the # symbol.
If so, how do you write a literal date in an SQL query for executing against SQL server?
Thanks, Ian.
Use the Convert function against the string representation. e.g. with the
date as yyyy-mm-dd hh:mm:ss
CONVERT(datetim e, '2005-02-05 13:15:00', 120)
Look in BOL for the CONVERT function for the list of formats converted.
--
Terry Kreft
"Ian Hinson" <pp******@bigpo nd.net.au> wrote in message
news:Cy******** **********@news-server.bigpond. net.au... Hi,
Sometimes I find it handy to construct an sql string for action queries, and then run it directly against the database and/or connection instead of using Recordsets for simple updates. eg. This query works in MS Access (using dbs.Execute):
UPDATE Customer SET LastContact = #2/5/2005 13:15:00# WHERE Customer.Custom erID = 101;
I'm now upsizing an app to SQL server, using ADP front-end. Date/Time fields were converted (by the wizard) to MSSQL datetime fields.
I'm finding that Date/Time literal expressions (formatted as #m/d/yyyy hh:nn:ss#) are not acceptible to MSSQL? Running above using cnn.Execute gives SQL syntax error at the # symbol.
If so, how do you write a literal date in an SQL query for executing against SQL server?
Thanks, Ian.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bon |
last post by:
I have a mssql view I am translating to oracle syntax
One of the lines in the mssql view is like this:
DATO=CASE (isnull(loandate,1)) WHEN 1 THEN 'N' ELSE 'Y' END
In other words, the view will return a Y if loandate has a value, N if
it does not have a value
How can I accomplish the same with Oracle9?
|
by: Andre |
last post by:
Hello
Can anyone help me translate this from access so that it can work in mssql
(i need to get next value, but cannot use identity as if row is deleted,
another must get new next column number which would be same as deleted one)
Access;
INSERT INTO table
SELECT
(IIF(code<>Null,MAX(code)+1,1) AS code,
0 AS usercode
FROM table
|
by: thomas kern |
last post by:
hi,
i tried to insert a record into a mssql-table.
one column is DateTime.
i tried this one:
insert into fixtures (dategame) VALUES ('24.01.2003')
unfortunately i receive an error
-- error --
The conversion of a char data type to a datetime data type resulted in an
|
by: va |
last post by:
Why does this property "DateTime?" compile?
public DateTime? test
{
get
{
return DateTime.Now;
}
}
|
by: Metalzed |
last post by:
Hi I have a little problem
If I use the this C# code
DateTime.Now.ToString()
output = 2006-11-03 06:15:17
But if i use this code in MSSQL
(CONVERT(VARCHAR(35), { fn NOW() }))
output= Nov 3 2006 6:15AM
| |
by: gradeA |
last post by:
Hi,
I am having trouble inserting data into a datetime field in MSSQL. Here is the script I am trying to execute:
$now = date('d/m/Y g:i:s A');
mssql_query("INSERT INTO clients (created,modified,firstname,lastname,address,address2,addressnotes,city,province,countryIID,postalcode,homephone,password,email) VALUES...
|
by: pks83 |
last post by:
In MSSQL I am using datetime as the column type and trying to execute the below mentioned query
select time from tickets where ticket_id = '1';
when i execute the query on sql manager window it shows it correctly with seconds and milliseconds in the output like this
2008-01-30 13:58:04.000
But when i run the sql through PHP it replaces the seconds and milliseconds with AM/PM
sql1="select time from tickets where ticket_id = '1' ";
|
by: pks83 |
last post by:
In MSSQL I am using datetime as the column type and trying to execute the below mentioned query
select time from tickets where ticket_id = '1';
when i execute the query on sql manager window it shows it correctly with seconds and milliseconds in the output like this
2008-01-30 13:58:04.000
But when i run the sql through PHP 5.2.5 it replaces the seconds and milliseconds with AM/PM
sql1="select time from tickets where ticket_id = '1'...
|
by: akronymn |
last post by:
I have an mssql database that I need to migrate to mysql. For some reason though any queries to any columns of type datetime are returned in French in the following format:
7/avr/2004 14:00
This also includes all the text of an SQL dump which not surprisingly makes mysql unable to read the dump from the MSSQL db. I've checked that my windows regional setting is set to English. I'm at a loss as to why this is happening or how to fix it. I...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |