473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Updating dates

I am using a short date format (mm/dd/yy). When I enter in a date and run
my update query, it is not accepting the data it puts in 12/30/1899

Here is the response.write of my SQL statement.

UPDATE Problems SET STATUS = 'Received', ComputerName = '', FupDate =
02/28/2005, Priority = 'Medium', IM_CHG = '', ProblemType = 'OTHER' WHERE
TicketNumber = 5

Does the date need #'s around it?

Jul 22 '05 #1
1 1272
Dthmtlgod wrote:
I am using a short date format (mm/dd/yy).
Bad idea. You should use the less ambiguous ISO format (yyyymmdd for SQL
Server; yyyy-mm-dd for Access) when passing dates to your database
When I enter in a date
and run my update query, it is not accepting the data it puts in
12/30/1899

Here is the response.write of my SQL statement.

UPDATE Problems SET STATUS = 'Received', ComputerName = '', FupDate =
02/28/2005, Priority = 'Medium', IM_CHG = '', ProblemType = 'OTHER'
WHERE TicketNumber = 5

Does the date need #'s around it?


It depends on what database you are using, and what the datatype of your
column is (the format is irrelevant). If Access, if it's a date/time field
(which is what I suspect due to the 12/30/1899 result), then yes, #'s are
required. If it's a SQL Server datetime field, then quotes are required. of
course, if you use parameters, then you don't have to worry about delimiters
at all, as well as protecting yourself from sql injection. Here is how I
would run your update statement if my arm was twisted to make me create it
in vbscript instead of using a saved parameter query:

dim sSQL, cn, cmd, arParms
sSQL = "UPDATE Problems SET STATUS = ?, " & _
"ComputerName = ?, FupDate = ?, Priority = ?, " & _
" IM_CHG = ?, ProblemType = ? WHERE TicketNumber = ?"
arParms=array("Received", "", #2005-02-28#, "Medium", "", _
"OTHER", 5)
set cn=createobject("adodb.connection")
cn.open "<OLE DB connection string>"
set cmd=createobject("adodb.command")
cmd.commandtype=1
cmd.commandtext=sSQL
set cmd.activeconnection=cn
cmd.execute , arParms, 128
cn.close:set cn=nothing

HTH,
Bob Barrows
PS. Please don't make us guess what database you are using. Always include
this information.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #2

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

Similar topics

6
by: Simon | last post by:
Hello, I am trying to update some varchar2 fields, which are storing dates. I am trying to set a 'to date' with the next minumum from date i.e from date | to date 01/01/1901 ...
6
by: Marlene | last post by:
Hi All I have the following scenario, where I have found all the duplicates in a table, based on an order number and a part number (item).I might have something like this: Order PODate Rec...
3
by: Brett Romero | last post by:
Is there a way to update data in a DataTable cell? I have column dates that are string type. I want to add another column to this table: dt.Columns.Add(new DataColumn("Datecolumn2",...
1
by: jman | last post by:
i've got a script that runs for a while... each time thru a loop - i'd like to update a page element (i.e. a progress bar). but it doesn't seem to happen - because i think pages are not...
1
by: ltctom | last post by:
I have a DB with multiple entries for each SSN. If a particular SSN has 10 records, I want to loop through these to compare start dates for an event. If the start dates are the same, I want to...
9
by: Marianne160 | last post by:
Hi, I know there are various answers to this problem available on the web but none of them seem to work for me. I am using Access 2003 to make a form to look up data from a table. I have so far...
1
by: EyeHawk | last post by:
OK, hopefully somebody can help me out again. My next problem is updating 3 form fields (type list/menu option) that correspond to a date, one for month, one for day and one for year when the user...
9
by: LucasLondon | last post by:
Hi, Sorry, this is a bit of a lengthy one but I guess too much information is better than less! I have an excel worksheet that I update regulary with latest values from downloaded CSV files....
2
tdw
by: tdw | last post by:
Hi all, I have several ideas on how to do this, but am having difficulty putting the ideas together and figuring out the most efficient way to do this. I have a database of survey coordinate...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.