Home > Net >  In c # a datetime value transformation
In c # a datetime value transformation

Time:09-27

I respectively from the datetime year and month
String year=datetime. Value. The tostring ();
String the month=datetime. Value. The tostring ();
String strtime=year + month;
At this point I want to have strtime converted to type int to want how to do?
Tried several methods are an error, I may be using the wrong method consult predecessors taught specific how to operate it

CodePudding user response:

This code can you run? A datetime value attribute? Your code is written like that?
https://blog.csdn.net/farmwang/article/details/50664378
Give you share a o (date) (month) (year) link
The code also give you
 string year=DateTime. Now. Year. The ToString (); 
String the month=DateTime. Now. The month. The ToString ();
String strtime=year + month;
Int time=int. Parse (strtime);

CodePudding user response:

DateTime DateTime=DateTime. Now;
Int time=datetime. Year + datetime. The Month;

CodePudding user response:

CodePudding user response:

Do you want to do, is this? Want to get what

CodePudding user response:

Strong direct turn not

CodePudding user response:

The question is "what the heck are you doing
"Too talented, I could understand every word, is together, completely don't understand what are you doing

CodePudding user response:

refer to 6th floor wanghui0380 response:
question is "what the heck are you doing
"Too talented, I could understand every word, is together, completely don't understand what are you doing
take out again in the coming year and month into years alone, then int

CodePudding user response:

reference young programmer 1/f, small don's reply:
you can run the code? A datetime value attribute? Your code is written like that?
https://blog.csdn.net/farmwang/article/details/50664378
Give you share a o (date) (month) (year) link
The code also give you
 string year=DateTime. Now. Year. The ToString (); 
String the month=DateTime. Now. The month. The ToString ();
String strtime=year + month;
Int time=int. Parse (strtime);
thank you, I will write just don't know how to turn int finally,

CodePudding user response:

refer to the eighth floor novice ladies reply:
Quote: refer to 1st floor young programmers don's reply:
you can run the code? A datetime value attribute? Your code is written like that?
https://blog.csdn.net/farmwang/article/details/50664378
Give you share a o (date) (month) (year) link
The code also give you
 string year=DateTime. Now. Year. The ToString (); 
String the month=DateTime. Now. The month. The ToString ();
String strtime=year + month;
Int time=int. Parse (strtime);
thank you, I will write just don't know how to turn int finally,

You might as well write like this: int time=int. Parse (DateTime. Now. The ToString (" yyyyMM "));

CodePudding user response:

Don't understand, year, month is two Numbers, how to convert a number? Addition, subtraction, multiplication?
Date (with no time) data conversion and data type int only established under certain conditions (such as specifying the 1900-1-1 to 0, every 1 day 1),

CodePudding user response:

Year + month on behalf of what?

CodePudding user response:

You have nothing to this
Int year=DateTime. Now. The year;
Int year=DateTime. Now. The Month;
Int year=DateTime. Now. Day;

CodePudding user response:

What he means is supposed to transform the current year for integer (int), 201911

CodePudding user response:

references 9 f Bridge_go response:
Quote: refer to the eighth floor novice ladies reply:

Quote: refer to 1st floor young programmers don's reply:
you can run the code? A datetime value attribute? Your code is written like that?
https://blog.csdn.net/farmwang/article/details/50664378
Give you share a o (date) (month) (year) link
The code also give you
 string year=DateTime. Now. Year. The ToString (); 
String the month=DateTime. Now. The month. The ToString ();
String strtime=year + month;
Int time=int. Parse (strtime);
thank you, I will write just don't know how to turn int finally,

You might as well write like this: int time=int. Parse (DateTime. Now. The ToString (" yyyyMM "));


Use this!
  •  Tags:  
  • C#
  • Related