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

substract two date

I have a date field start_date.i want to substract that date from current date(machine date)and want to get the result as month
Feb 17 '12 #1
3 1952
Guido Geurs
767 Expert 512MB
Add this function in a Module in VBA:

Expand|Select|Wrap|Line Numbers
  1. Function MonthDiff(MYdate As Variant) As Variant
  2.     MonthDiff = Str((DateDiff("m", Now, MYdate)))
  3. End Function
Use the function (see Attachment)

Attached Images
File Type: jpg ScreenCap 1.JPG (7.7 KB, 208 views)
Feb 18 '12 #2
NeoPa
32,556 Expert Mod 16PB
I believe the question is SQL Server (T-SQL) related Guido ;-)
Feb 20 '12 #3
You can use given below function in sql server..
DATEDIFF(MM,start_date,getdate())
Feb 21 '12 #4

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

Similar topics

38
by: | last post by:
I have a script... ----- <SCRIPT language="JavaScript" type="text/javascript"> <!-- function makeArray() { for (i = 0; i<makeArray.arguments.length; i++) this = makeArray.arguments; } ...
16
by: Bernd Hohmann | last post by:
Hi there, we're currently convert an old ISAM application to Java and DB2. Among the load of problems we found the reports which have user selections like "select all data between mm/yyyy and...
2
by: David Olsen | last post by:
Would any of you kind souls now how to put into an unbound text box the week commencing date for the current week which you are in, so that the report heading would say something like for example,...
7
by: developer | last post by:
I want to substract a number of month from a specific date. someone have a easy solution ? Thanks
4
by: Russell | last post by:
I have an assignment that I have to complete. I have to write a windows app in C#. Here is the spec: 1/ Date Comparison Build a program that will find the number of days between two dates. You...
2
by: Łukasz W. | last post by:
Hello everybody ! How is it in Selection Formula to work with Date type, for example to deduct 7 days, week, month, year from CurrentDate. I'm trying to use such a stetement (CurrentDate - Date...
3
by: CBN Media | last post by:
Hi, I need to calculate a date which is current date (Now) minus x days. I looked at DateTime, it has a fairly large number of methods to add something to a date, but for substracting is just...
16
by: Atley | last post by:
I am trying to get a overall difference on two dates, I can get the difference in Years, Months, Weeks, Days, Hours, Minutes, Seconds, no problems... What I cannot seem to figure out is how to...
21
by: shelleybobelly | last post by:
I'm looking to return DATE ONLY for yesterday's date. No seconds, milliseconds. Formatted either yyyy/mm/dd or mm/dd/yyyy. VB does it so easily Date()-1 will return 03/27/2007 if today is...
6
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I am trying to compare just the time portion of two variables that are of date time part. For example I have dtdate1= 2/2/07 10:00:00 dtdate2=3/4/07 9:00:00 so for the comparision I would...
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
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,...
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
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...
0
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...

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.