Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to Remove Year OR Month From Datetime Object.?

Suppose i Register: DomainName
Select: How many Years: 1 2 3 4 5...
So, after i set Current Date, put code behind for Cureent date+1year and -1 month...
Posted
Updated 23-Feb-15 0:53am
v2
Comments
CHill60 21-Feb-15 5:54am    
A bit more detail please.
What do you mean by "remove"? What are you trying to do?
What have you tried?
BillWoodruff 21-Feb-15 7:56am    
You can't remove the internal fields of a DateTime structure: you can ignore them.
Kuthuparakkal 21-Feb-15 11:35am    
Pls explain more
[no name] 21-Feb-15 11:58am    
Can u explain? Question is not clear.

You can't remove portions of the datetime object. Instead when you use the value from a datetime you can format it as you like. See
- DateTime.ToString Method (String)[^]
- Custom Date and Time Format Strings[^]
 
Share this answer
 
VB
DateTime.Now.ToString("MM/yyyy");// will display 02/2015
DateTime.Now.ToString("dd/yyyy");// will display 21/2015
DateTime.Now.ToString("dd/MM");// will display 21/02
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900