| | |
Date Formatting Calculations!!!
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2006
Posts: 45
Reputation:
Solved Threads: 0
Hi All,
My application requires lot of Date formatting calculations.
Here is mynew issue, which i am trying for last two days.
Hope someone can help me in this
I have startDate as First date of current month
endDate as todays date.
eg: 2/1/2007 ---- 2/19/2007
Now what I want to calculate 3/10/2007 and 1/12/2007 from this data.
That is I want to calculate 2/19/2007 + (difference of 2/19/2007 and 2/1/2007)
2/1/2007 - (difference of 2/19/2007 and 2/1/2007)
Hope I am not confusing you.
Thanks
My application requires lot of Date formatting calculations.
Here is mynew issue, which i am trying for last two days.
Hope someone can help me in this
I have startDate as First date of current month
endDate as todays date.
eg: 2/1/2007 ---- 2/19/2007
Now what I want to calculate 3/10/2007 and 1/12/2007 from this data.
That is I want to calculate 2/19/2007 + (difference of 2/19/2007 and 2/1/2007)
2/1/2007 - (difference of 2/19/2007 and 2/1/2007)
Hope I am not confusing you.
Thanks
Kind of confused...
Let's simplify this a little bit by assigning variable names to each date.
A = 2/1/2007 (First day of current month)
B = 2/19/2007 (Current date)
C = 3/10/2007 (Some future date)
D = 1/12/2007 (Some past date)
Do the parenthese describe your requirements?
Now, what are you trying to calculate and what do you expect as a result. When I say result, I mean - are you expecting a date. Are you expecting a difference such as number of days, hours, minutes etc...
And what programming language is your preferred choice? VB.Net, C#, Javascript, etc.
Let's simplify this a little bit by assigning variable names to each date.
A = 2/1/2007 (First day of current month)
B = 2/19/2007 (Current date)
C = 3/10/2007 (Some future date)
D = 1/12/2007 (Some past date)
Do the parenthese describe your requirements?
Now, what are you trying to calculate and what do you expect as a result. When I say result, I mean - are you expecting a date. Are you expecting a difference such as number of days, hours, minutes etc...
And what programming language is your preferred choice? VB.Net, C#, Javascript, etc.
-Mike
A = 2/1/2007 (First day of current month)
B = 2/19/2007 (Current date)
C = 3/10/2007 (Some future date)
D = 1/12/2007 (Some past date)
You want to know how to calculate the following right?
B + (B-A) = C (This actually gives me 3/9/2007)
A - (B-A) = D (This actually gives me 1/14/2007)
Here's some code in C#. I hope this helps.
B = 2/19/2007 (Current date)
C = 3/10/2007 (Some future date)
D = 1/12/2007 (Some past date)
You want to know how to calculate the following right?
B + (B-A) = C (This actually gives me 3/9/2007)
A - (B-A) = D (This actually gives me 1/14/2007)
Here's some code in C#. I hope this helps.
c# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.Text; namespace Test { class Program { static void Main(string[] args) { DateTime A = new DateTime(2007, 2, 1); DateTime B = new DateTime(2007, 2, 19); //B = DateTime.Now; // Use this to calculate from current date DateTime C, D; TimeSpan DiffBminusA = (B - A); C = B.AddDays(DiffBminusA.Days); D = A.AddDays(-DiffBminusA.Days); Console.Write( "\n\n\nA==" + A.ToString() + "\nB==" + B.ToString() + "\nDiffBminusA==" + DiffBminusA.ToString() + "\nDiffBminusA.Days==" + DiffBminusA.Days.ToString() + "\nC==" + C.ToString() + "\nD==" + D.ToString() + "\n\n\n"); } } }
-Mike
![]() |
Similar Threads
- Looking for List Box help, please! (VB.NET)
- insert date into databases (PHP)
- Date formatting? (Pascal and Delphi)
- Simple Time/Date Program (C)
Other Threads in the ASP.NET Forum
- Previous Thread: Web form that places input into document
- Next Thread: checkboxcolumn in datagrid
Views: 2359 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax appliances asp asp.net beginner box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class compatible complex confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datalist deadlock deployment development dgv dialog dropdown dropdownmenu dynamic edit embeddingactivexcontrol feedback fileuploader findcontrol flash flv folder form forms grid gridview homeedition hosting iis image index javascript jquery languages list maps menu mobile mssql multistepregistration nameisnotdeclared novell objects order problem profile ratings refer relationaldatabases response.redirect rotatepage search security serializesmo.table sessionvariables silverlight sql ssl tracking treeview typeof update validatedate validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopment wizard xml





