473,406 Members | 2,705 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.

How to arrive remaining Months and Date of Current Year in Query?

1
Hello,

I like to use a function like DateDiff to know Number of Years, Months, and Days between Days. As an Example, 5 Years, 10Months, 28Days for date between (JoiningDate)02Jan05,(LastDate)30Nov10.

The Number of Years is working fine in my Query using DateDiff. But I could not get 10 Months and 28 Days. Help me please.

Ramli
Dec 5 '10 #1
2 2184
i am giving you function to retrive day,month,year from
date i hope it will help you

Syntax : datediff(datepart,1st date,2nd date)
Expand|Select|Wrap|Line Numbers
  1.          declare @day varchar(10)
  2.          declare @month varchar(10)
  3.          declare @year varchar(10)
  4.        select @day   = datediff(day,1st date,2nd date) 
  5.        select @month = datediff(month,1st date,2nd date)            
  6.        select @year  = datediff(year,1st date,2nd date) 
  7.  
Dec 5 '10 #2
NeoPa
32,556 Expert Mod 16PB
We don't simply code for you, in the absence of any attempt to work on a solution for yourself. What I can tell you is that your procedure will need to determine how many complete years are involved, before taking that many years away then determining how many complete months are involved. The same logic is then applied to the remainder for the days before you have a reliable result. There is no function available already to do this for you.
Dec 5 '10 #3

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

Similar topics

4
by: Dave | last post by:
Hi, Can anyone tell me a simple way of inserting some sort of code into a Dreamweaver template (it goes at the bottom of the page in Copyright info) that will cause the current year to be...
3
by: Dixie | last post by:
How do I parse out the 20 from the current year (2005). I can get the last 2 numbers on their own, but have been unable to get the first two on their own. TIA dixie
6
by: Sridhar | last post by:
Hi, I need to display a calendar that shows all the months of an year. In that, I need to show different colors for certain events. I know how to display a calendar for a certain month but I am...
5
by: mchlle | last post by:
I have a form that allows the user to choose and open a report from a drop down box based on the semester they choose from an option box. Option 1-3 are Spring, Summer and Fall and each semester...
5
by: Jimmy | last post by:
How do I set the default value of a text box (date/time) to 1/1/Current Year... i.e 1/1/2006 this year, 1/1/2007 next year?
4
by: john | last post by:
I have an unbound field in which I would like to show january 1 of the current year like this 01-01-2007. I tried this code but it doesn't work: =dateserial(Year(date()),1,1) Can someone help me...
3
by: remya1000 | last post by:
i'm using ASP with MSAccess as database. i have two buttons and two textbox in my page. when i press my first button (First month) i need to display the current month in one textbox and last one...
8
by: sanika1507 | last post by:
Hi all how to write this 01/01/ and whatever year is coming as current year -1....in an SQL query .i want it to write it in a stored proc... using SQL server 2000. Thanks in advance . .
2
by: deepikashalini | last post by:
hi, Im storing Issue date in database. Issuedate stored as varchar. and then compare to Passing string date('03/06/2008') what is query to compare storing varchar date to passing string...
5
by: tbeers | last post by:
Good morning. I am running a timecard program in Access 2007 and it seems that the users have trouble entering the correct year when entering the date in the date field. Date field entry format...
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
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:
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
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,...
0
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...

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.