CFanatic

Go Back   CFanatic > Programming > C# Programming

Join CFanatic Forum Now

I want to return the date a week ago from today topic posted under C# Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 04-03-2008, 02:27 PM
Junior Member
 
Join Date: Apr 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rocket452 is on a distinguished road
| More
I want to return the date a week ago from today

I am using System.DateTime.Now.ToShortDateString() to get today's date.

I want to return this date minus 7 days(a week ago) so I can use it as a parameter in a SQL query.

I know that System.DateTime.Now has a Subtract method, but I dont think it will suit my purposes.

thanks in advance
Reply With Quote
  #2  
Old 09-08-2008, 02:58 AM
Junior Member
 
Join Date: Jul 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
praspam is on a distinguished road
| More
Re: I want to return the date a week ago from today

select cast(DATEDIFF(dd, 7, GetDate())as datetime)
Reply With Quote
  #3  
Old 12-08-2008, 11:29 AM
Junior Member
 
Join Date: Dec 2008
Location: India
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
selvanshankar is on a distinguished road
| More
Re: I want to return the date a week ago from today

Quote:
Originally Posted by Rocket452 View Post
I am using System.DateTime.Now.ToShortDateString() to get today's date.

I want to return this date minus 7 days(a week ago) so I can use it as a parameter in a SQL query.

I know that System.DateTime.Now has a Subtract method, but I dont think it will suit my purposes.

thanks in advance
pls let me knw hw to substrct 7 days from today...
Reply With Quote
  #4  
Old 01-23-2009, 05:16 AM
Junior Member
 
Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
medink is on a distinguished road
| More
Re: I want to return the date a week ago from today

I got this working

DateTime today = DateTime.Today;
DateTime back = today.Subtract(TimeSpan.FromDays(7));
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Functions that return two values psppb C++ Programming 2 02-12-2008 10:11 PM
Beginners Question on 'return' MartijnMulder C# Programming 1 12-08-2006 02:33 PM
New Firefox Version Fixes 7 Security HolesMozilla this week pushed out a new version NewsBot News 0 09-16-2006 09:33 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 03:32 PM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board