473,406 Members | 2,387 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,406 software developers and data experts.

add 28 years aagin

S G
HI all,
This has puzzled me all morning. I have a int field which reads
19691124 (UK dates) this is actually a date 24 November 1969 I need to
add 28 years to this making it 19971124 but I’m stumped!
Any ideas anyone?
Cheers
Sean


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
4 3150
"S G" <an*******@devdex.com> wrote in message news:3f*********************@news.frii.net...
HI all,
This has puzzled me all morning. I have a int field which reads
19691124 (UK dates) this is actually a date 24 November 1969 I need to
add 28 years to this making it 19971124 but I'm stumped!
Any ideas anyone?
Cheers
Sean


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


If you want a DATETIME returned then

SELECT DATEADD(YEAR, 28, '19691124')

If you want an INT returned then

SELECT CAST(CONVERT(CHAR(8),
DATEADD(YEAR, 28, '19691124'),
112) AS INT)

Regards,
jag
Jul 20 '05 #2
S G wrote:
HI all,
This has puzzled me all morning. I have a int field which reads
19691124 (UK dates) this is actually a date 24 November 1969 I need
to add 28 years to this making it 19971124 but I'm stumped!


Select (DateField + 280000) as NewDateField
From Table

By the way, I don't like too much that way of storing dates.

Anyway...

Bye

Alberto
Jul 20 '05 #3
Sorry, forgot that your input is an INT. Replace the string '19691124'
with CAST(19691124 AS CHAR(8)).

"John Gilson" <ja*@acm.org> wrote in message news:Rh********************@twister.nyc.rr.com...
"S G" <an*******@devdex.com> wrote in message news:3f*********************@news.frii.net...
HI all,
This has puzzled me all morning. I have a int field which reads
19691124 (UK dates) this is actually a date 24 November 1969 I need to
add 28 years to this making it 19971124 but I'm stumped!
Any ideas anyone?
Cheers
Sean


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


If you want a DATETIME returned then

SELECT DATEADD(YEAR, 28, '19691124')

If you want an INT returned then

SELECT CAST(CONVERT(CHAR(8),
DATEADD(YEAR, 28, '19691124'),
112) AS INT)

Regards,
jag

Jul 20 '05 #4
"Albe V°" <va*****************@hotmail.com> wrote in message
news:Iq**********************@twister1.libero.it.. .
S G wrote:
HI all,
This has puzzled me all morning. I have a int field which reads
19691124 (UK dates) this is actually a date 24 November 1969 I need
to add 28 years to this making it 19971124 but I'm stumped!
Select (DateField + 280000) as NewDateField
From Table


This approach will be problematic with a leap year, e.g.,
adding 1 year to 20000229.

Regards,
jag
By the way, I don't like too much that way of storing dates.

Anyway...

Bye

Alberto

Jul 20 '05 #5

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

Similar topics

9
by: Didi H. | last post by:
Hi, in our company we are currently thinking about to do new project in .NET. I like this idea but there is another group that has a totally different opinon. Yesterday I got the following email,...
7
by: Bambero | last post by:
Hello all Problem like in subject. There is no problem when I want to count days between two dates. Problem is when I want to count years becouse of leap years. For ex. between 2002-11-19...
2
by: pierrelap | last post by:
Hello, I need to code a query that: 1-counts the number of time two companies have been in a deal together 2-in the five years that preceded the deal Lead Participant DealDate AAA BBB ...
6
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns...
37
by: Gregc. | last post by:
G'day I'm trying to work out the number of years since 1970, here is my code: include <stdio.h> #include <time.h> const int SEC_IN_MIN = 60; const int SEC_IN_HOUR = SEC_IN_MIN * 60;
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...
0
by: AJAY SHARMA | last post by:
Can a critic of book 100 Years of E=mc2 be without NAME , PLACE and IDENTITY ? 100 Years of E =mc2 For details...
0
by: jyothi.priya143 | last post by:
Hi Friends, Urgent Requirement of FRESHERS (0 - 2 Years) are here for u now... Here u can upload a soft copy of ur resume in one click... Here U can also get Jobs-Freshers & Experienced, Sample...
2
by: ichew | last post by:
I have two dates - Date Joined and Actual Last Day. How do I find the YIS in for format of Years and Month from these two dates. Eg, Date Joined: 28/06/1971 and Actual Last Day: 24/01/2007, then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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.