473,757 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datetime problems

The following code gives me the error "syntax error converting datetime
to character string" im using access 2003 as a front end and sql server
2000 as a backend

strSQL = "INSERT INTO tblDeal (dealRecipient, dealStartDate,
dealEndDate, dealType) VALUES (" & Me.txtrec.Value & "," & "'#" &
Me.dealStartDat e.Value & "#'" & "," & Me.dealEndDate. Value & "," & "'"
& Me.dealType & "'" & ")"

The specific part its complaining about is "'#" &
Me.dealStartDat e.Value & "#'"

I don't know how to format it for a date in the sql statement any other
way then that, can anyone please help?

Nov 13 '05 #1
2 1326
Is this a pass-through query (i.e.: running on SQL Server)? If so, SQL
Server uses ', not #, to delimit dates.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Beacher" <be*****@gmail. com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
The following code gives me the error "syntax error converting datetime
to character string" im using access 2003 as a front end and sql server
2000 as a backend

strSQL = "INSERT INTO tblDeal (dealRecipient, dealStartDate,
dealEndDate, dealType) VALUES (" & Me.txtrec.Value & "," & "'#" &
Me.dealStartDat e.Value & "#'" & "," & Me.dealEndDate. Value & "," & "'"
& Me.dealType & "'" & ")"

The specific part its complaining about is "'#" &
Me.dealStartDat e.Value & "#'"

I don't know how to format it for a date in the sql statement any other
way then that, can anyone please help?

Nov 13 '05 #2
Douglas J. Steele wrote:
Is this a pass-through query (i.e.: running on SQL Server)? If so, SQL
Server uses ', not #, to delimit dates.


Also formatting:
{d'2005-05-31'}
or just plain
'20050531'

You might get away with American format but given the confusion between
American and British format dates I'd stick to international format just
so's the code can look correct at a glance.

--
[OO=00=OO]
Nov 13 '05 #3

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

Similar topics

0
5161
by: Symon R | last post by:
This is a bit of a weird one that I haven't yet been able to solve - I'm hoping someone out there can disprove my findings and tell me where I've gone wrong! I have designed a web service that accepts messages from .NET clients. The web method call includes an object as one of it's parameters - this reflected object has been given a property called "FutureDelivery" and expects a DateTime value. The clients may be in different timezones...
1
14975
by: Chris | last post by:
Hello, I'm having some problems right now with something that would seem to be rather simple (and probably is). But, the solution is escaping me right now. Currently, I have created a data structure with a timestamp in it. This is created in a DLL written in C++. The command that I use to get the timestamp is:
1
5079
by: Kevin | last post by:
Hi All I am having a problem retrieving a Date value from an Access 2000 database using the OLEDbProvider. Can someone tell me please how to create a DateTime Object with the date fro m the Database, I need the database date to subtract it from another date I have to gain the number of days that have elapsed. I just cannot seem to get this DateTime thing correct. The field in my Access Database is defined as a short date. This is kind...
38
807
by: nobody | last post by:
I know that given a FormatString and a DateTime you can use DateTime.ToString(...) to convert the DateTime to a String. My question is how can you turn that around? Given a String and a FormatString, how can you convert the String back to a DateTime? DateTime.Parse(...) doesn't use the FormatString. Now admitedly, if the format string is just "MM", it can't be done. But if the format string is "yyyyMMdd", or "ddMMMyyyy hhmmsst", it...
11
7247
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why only that I have to listen to them because they know it better. They told also that in a business situation it is better to use datetime.parseexact for changing cultures and not to use the globalization setting. I did not give them this sample,...
1
2881
by: Ugur Ekinci | last post by:
Hi , I have two Sql Server 2000 on seperate machines , First one accepts datetime format like ("dd.MM.yyyy hh:mm:ss") And Second one accepts datetime format like ("MM.dd.yyyy hh:mm:ss") 1- Date formats are different because of SQL Collation? 2- Do regional Settings affect Sql date format? 3- (Important) When inserting a datetime into first server there is no problem (15.12.2000 12:12:12) , but when I insert into second server (if...
0
1442
by: H5N1 | last post by:
Hi there I know that a problem of different datetime strings formatting between asp.net and ms sql has been covered here widely, but what I couldn't find is the 100% safe way of getting datetime values from ms sql, processing them in asp.net and getting them back into sql without any risk with inconsistent Culture settings etc. My question is: wouldn't keeping the datetime variables all the time in datetime type, without any String...
5
2601
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field (MSSQL Server) it worked on my test machine. If I run the same application on another machine with different regional settings is not working. I tried with date_default_timezone_set to change timezone but is not changing. After...
5
3491
by: Michel Posseth [MCP] | last post by:
Hello we have encountered the following problems with the date time picker control A : datetime picker control gives focus to last entered field when moving back and forward with focus how do we reset this to the first field ? B : datetime picker in DD-MM-YYYY default format ( europe , NL-NL localization ) refuses an entry of 31 on the DD filed cause the month is already chosen to the current mont ( (02) februari wich only has 28...
10
1492
by: Jeff | last post by:
Hey ..NET 2.0 I'm about to create 2 input parameters for a method. These are 2 DateTime parameters - one named "from" and another named "to"... - from and to DateTime values... Okay the trick is that the "from" DateTime should be like this 01.<MM>.<YYYY ss:mm.hh which means that today is the 03.12.2007 then the
0
9487
marktang
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...
0
10069
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9735
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...
1
7285
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
6556
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
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
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
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
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...

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.