.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old May 7th, 2008, 04:05 PM
fletchsod's Avatar
fletchsod fletchsod is offline
I lov C in AIX/Linux, hate C++
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Location: Jacksonville, Florida
Posts: 1,491 fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 2 Days 15 h 38 m 46 sec
Reputation Power: 7
DateTime - How do I set the year to year 2000?

I was wondering how do I set the year to year 2000?

Code:
System.DateTime oDateTime = new System.DateTime(); //.Year("2000"); //.Year(-100); 


Thanks...

Reply With Quote
  #2  
Old May 7th, 2008, 04:24 PM
f'lar's Avatar
f'lar f'lar is offline
Senior WeyrLeader
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Aug 2003
Location: WI
Posts: 3,737 f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level)f'lar User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 3 Days 8 h 6 m 39 sec
Reputation Power: 675
Send a message via Google Talk to f'lar
Do you want to set the system time of the current computer, do you want to use Jan 1 for the the month and day, or do you want to go back exactly 8 years?
__________________
Primary Forums: .Net Development, MS-SQL, C Programming
VB.Net: It's not your father's Visual Basic.

[Moving to ASP.Net] | [.Net Dos and Don't for VB6 Programmers]

Reply With Quote
  #3  
Old May 7th, 2008, 04:36 PM
fletchsod's Avatar
fletchsod fletchsod is offline
I lov C in AIX/Linux, hate C++
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Location: Jacksonville, Florida
Posts: 1,491 fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level)fletchsod User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 2 Days 15 h 38 m 46 sec
Reputation Power: 7
I just want to set the oDateTime object to jan 1, 2000 or the Year() object to the oDateTime object to Year 2000 regardless of the day or month.

I have no desire to set the computer's (or PC's) system time to whatever date.

Reply With Quote
  #4  
Old May 7th, 2008, 04:41 PM
eclipsed4utoo eclipsed4utoo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2005
Posts: 90 eclipsed4utoo User rank is Sergeant (500 - 2000 Reputation Level)eclipsed4utoo User rank is Sergeant (500 - 2000 Reputation Level)eclipsed4utoo User rank is Sergeant (500 - 2000 Reputation Level)eclipsed4utoo User rank is Sergeant (500 - 2000 Reputation Level)eclipsed4utoo User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 7 h 42 m 58 sec
Reputation Power: 18
do you mean like this?

Code:
DateTime newDate = DateTime.Now.AddYears(-8);

Reply With Quote
  #5  
Old May 7th, 2008, 05:00 PM
LyonHaert's Avatar
LyonHaert LyonHaert is offline
Arcane Scribbler
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2005
Location: Indianapolis, IN
Posts: 1,538 LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 4 h 19 m
Reputation Power: 357
Code:
C#
//2000-01-01 00:00:00
DateTime date = new DateTime(2000, 1, 1, 0, 0, 0);

Code:
C#
//2000-??-?? ??:??:??
DateTime n = DateTime.Now;
DateTime date = new DateTime(2000, n.Month, n.Day, n.Hour, n.Minute, n.Second);
__________________
Joel B Fant - LyonHaert.net

2 + 2 is... 10... in base 4

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > DateTime - How do I set the year to year 2000?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway