subtracting dates

  • Thread starter Thread starter Abul Hasan Lakhani
  • Start date Start date
A

Abul Hasan Lakhani

hello everyone,

i want to subtract 30 days from the current date and get the resulting date in vb.net. How can I acheive this result?
i have tried the same by subtracting 30 from NOW() but its not working.

Waiting for immediate feedback.
 
Dim Today As DateTime = DateTime.Now( )
Dim Span As New TimeSpan(30, 0, 0, 0)
Dim TodayMinusThirty As DateTime = Today.Subtract(Span)
MessageBox.Show(TodayMinusThirty.ToString)


hope that helps..
Imran.
hello everyone,

i want to subtract 30 days from the current date and get the resulting date in vb.net. How can I acheive this result?
i have tried the same by subtracting 30 from NOW() but its not working.

Waiting for immediate feedback.
 
Dim d as DateTime

d = DateTime.Now - TimeSpan.FromDays(30)

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.framework/<#[email protected]>

hello everyone, i want to subtract 30 days from the current date and get the resulting date in vb.net. How can I acheive this result? i have tried the same by subtracting 30 from NOW() but its not working. Waiting for immediate feedback.
--
Abul Hasan Lakhani This post contained attachments. By default, NewsGator will not download attachments, but can be configured to do so. If you wish to automatically download attachments for this newsgroup, go to NewsGator/Subscriptions, select this group and click Edit, and change the Options.


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004



[microsoft.public.dotnet.framework]
 
Abul,
In addition to the other comments, I normally add -30 days to a date to
subtract the days:

Something like:

Dim theDate As DateTime = DateTime.Now.AddDays(-30)

Hope this helps
Jay

hello everyone,

i want to subtract 30 days from the current date and get the resulting date
in vb.net. How can I acheive this result?
i have tried the same by subtracting 30 from NOW() but its not working.

Waiting for immediate feedback.
 
Back
Top