473,394 Members | 1,902 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,394 software developers and data experts.

Cann't get values in a Date/Time column to increment by a set number of years

mikek12004
200 100+
I have a column date with 'Date/Time' type which holds values like this
8/4/2009 for the 4th day of the 8th month of 2009, due to some bug many records write instead 8/4/4009 so I want for those record to put the write date. The whole thing is for a asp script so for there I could easily write a SQL query like
Expand|Select|Wrap|Line Numbers
  1. update DailySnapStocks set Date='4/8/2009' where Date='4/8/4009' and Symbol='FTSE' 
  2.  
which didn't work but is pretty much what I want to do any help?
Nov 10 '09 #1
9 1968
ajalwaysus
266 Expert 100+
Without knowing what the error message is, I would say try this

Expand|Select|Wrap|Line Numbers
  1. update DailySnapStocks set Date=#4/8/2009# where Date=#4/8/4009# and Symbol='FTSE' 
If this is not it, please post the error, or tell us if there isn't one.

-AJ
Nov 10 '09 #2
mikek12004
200 100+
Tried
Expand|Select|Wrap|Line Numbers
  1. update DailySnapStocks set Date=#4/8/2009# where Date=#4/8/4009# and Symbol='FTSE'  
  2.  
got a "Syntax error in UPDATE statement" popoup and when I press help I see
"Syntax error in UPDATE statement. (Error 3144) "
Nov 10 '09 #3
MMcCarthy
14,534 Expert Mod 8TB
OK try this one ...

Expand|Select|Wrap|Line Numbers
  1. update DailySnapStocks 
  2. set [Date]=#4/8/2009# 
  3. where [Date]='4/8/4009' 
  4. and Symbol='FTSE'
  5.  
Date is a reserved word in Access and should not be used on its own as a field name. Using the square brackets will help with this but I would recommend changing the field name.
Nov 10 '09 #4
topher23
234 Expert 100+
Remember that Date can sometimes be tricky as it's also a function.

Try this one out:
Expand|Select|Wrap|Line Numbers
  1. UPDATE DailySnapStocks SET DailySnapStocks.[Date] =#4/8/2009#
  2. WHERE (((DailySnapStocks.[Date] = #4/8/4009#) AND ((DailySnapStocks.Symbol)='FTSE'));
This is a bit more wordy, since I built it in the Query Editor.

EDIT: Looks like we posted on top of each other, Mary!
Nov 10 '09 #5
MMcCarthy
14,534 Expert Mod 8TB
Great minds think alike ... and all that :D
Nov 10 '09 #6
mikek12004
200 100+
Well...msquared's solution got me an 3464 Error
topher23's Worked (with removing an extra parenthesis),
a new (better) new possible solution which saw and deals with all updates at once is
update DailySnapStocks set date=DATEADD(yyyy, 1000, DailySnapStocks.date) where Symbol='FTSE' and date like '%40%'
This is MSSQL code which worked perfect in SQL server '08 but in Access
made like this
update DailySnapStocks set date=DATEADD(yyyy, 1000, [Date]) where Symbol='FTSE' and date like '*40*'
got a 3144 Error any ideas?
Nov 11 '09 #7
MMcCarthy
14,534 Expert Mod 8TB
Try this ...


Expand|Select|Wrap|Line Numbers
  1. update DailySnapStocks set date=DATEADD("yyyy", -2000, [Date]) where Symbol='FTSE' and date like '*40*' 
  2.  
Nov 11 '09 #8
mikek12004
200 100+
Worked like this
update DailySnapStocks set [date]=DATEADD("yyyy", -2000, [Date]) where Symbol='FTSE' and [date] like '*40*'
At last I can continue, you cannot imagine how many hours I spent wondering why it is not working (I thought that the SQL view was identical to the mssql which I worked in sql studio since they are both from microsoft...)
Anyway thanks a lot both of you for your quick replys
Nov 11 '09 #9
MMcCarthy
14,534 Expert Mod 8TB
Glad you got it working. Unfortunately the syntax in Access is quite different to MS SQL outside of the basics of course. You'll get there eventually with trial and error.
Nov 11 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Tim Davidge | last post by:
Hi folks, been a while since I have posted a plea for help and I think I have forgotten everything I learnt from the helpful contributors to this newsgroup, that said however : I'm trying to...
4
by: Tony | last post by:
Hey guys, I use Google Groups quite a bit as it is an enormous wealth of information, and now I need some help. I have created a query using parameters to capture a range of date, the date is...
8
by: Lyn | last post by:
I am trying to get my head around the concept of default, special or empty values that appear in Access VBA, depending on data type. The Access Help is not much (help), and the manual that I have...
1
by: John Feeley | last post by:
am tring to add a number of years to a dob. im doing this by adding my date+years*365.26 I get a string of numbers. I then convert the number in the next column to actual date again. I'm getting...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
6
by: gre1unix | last post by:
I am new to VBA Access. I create "mytable" with 2 columns from existing main table by giving start date and end date. Given below is mytable. First column: dt( date hr:min:sec format ) Second...
1
by: Sigmazen | last post by:
Hi I am looking in to utilising the new functionality of DPSIs on zOS UDB (DB2 v8), but I have a question regarding the following scenario. - The first table is an Account table whose columns...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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...
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
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...

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.