|
Red flags all over all your posts.
|
|
|
|
|
Hello all
I am building a website and I want to store the current time in a database, thats not a problem.
But I also want to make the time format changable. For example if I have "May 2 2009" stored in the database and I decide I want to change the format to "5/2/2009", I need to either update the database or use a neutral date format that can be converted to the date format I want.
Any tips on this? I thought about using timestamp, but cant rellay see where it fits in
Thanks
|
|
|
|
|
Just save the datetime in DateTime format in database, not in string.
|
|
|
|
|
|
He means that a datetime is a number[^], and as such, is neutral. To quote;
SQL Server uses 8 bytes to store the datetime data type. The first 4 bytes make up an integer value that represents the number of days since January 1, 1900. The second 4 bytes are an integer value that represents the number of milliseconds since midnight.
When you send a date to the database, do you convert it to a string that get's included in your (text) command? If so, then you can get errors converting from/to the wrong format. If you send it as a number, then it will be interpreted as a "days past since date 1"-number.
Try casting a date to float/integer, and see what happens
I are troll
|
|
|
|
|
|
If you want to catch the messages, use this in your form class.
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
}
|
|
|
|
|
Hi there......
Thanks for your help. I need to know how to process a WM_CHAR message sent by other application using SENDMESSAGE API.
I want to receive any keyboard stroke. As you suggested I used :
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_CHAR)
MessageBox.Show(m.Msg.ToString());
}
But it gives an error for WM_CHAR. So please tell me how to catch any keyboard event.
Thanks a ton.....
Vishal Moharikar.
|
|
|
|
|
|
Hi there...
Sorry, if I am asking any stupid questions.. but just tell me how would I come to know whether the received message is a keyboard event or any other windows message.
I just want to handle the keyboard messages fired by any other application.
Thanks....
Vishal Moharikar.
|
|
|
|
|
We can use int32.TryPrase("1231312",out tmpInt32Value) for normal situtations.
But the following code,
string outputString = (12345).ToString("ABCDE-0000000000");
I do not have a good idea to read such string ABCDE-0000012345
Especially when the format string is "ABCDE-0066000880"
modified on Tuesday, May 26, 2009 3:09 AM
|
|
|
|
|
and... what is the question ?
|
|
|
|
|
Thank you.
I do not have a good idea to convert string ABCDE-0000012345 to int32
Especially when the format string is "ABCDE-0066000880"
|
|
|
|
|
What kind of strings are that ?
Do you mean :
ABCDE-0000012345 = 12345
ABCDE-0066000880 = 66000880
???
|
|
|
|
|
when the format string is "ABCDE-000066000880";
int 1234 custom formated value is "ABCDE000066123884"
My question is how to get the int value by custom format string "ABCDE-000066000880" and formatted string "ABCDE000066123884".
|
|
|
|
|
Your going to format your interger to a predefine format.
Example 1
<br />
string outputString = (12345).ToString("ABCDE-0000000000");<br />
Example 2
<br />
string outputString = (12345).ToString("ABCDED-0000000000");<br />
If your are expecting that the output of Example 1 is ABCDE-0000012345 you are wrong because "E-0" means Scientific notation.
Note: If any of the strings "E", "E+", "E-", "e", "e+", or "e-" are present in the format string and are followed immediately by at least one '0' character, then the number is formatted using scientific notation with an 'E' or 'e' inserted between the number and the exponent. The number of '0' characters following the scientific notation indicator determines the minimum number of digits to output for the exponent. The "E+" and "e+" formats indicate that a sign character (plus or minus) should always precede the exponent. The "E", "E-", "e", or "e-" formats indicate that a sign character should only precede negative exponents.
See Custom Numeric Format String[^ for more details.
Happing Coding...
|
|
|
|
|
Thank you for your answer.
And ,i made a bad formatted sample. Sorry to everyone.
we know that code (1234).ToString("ABCD-000066000880") 's value is ABCD-000066123884.
And I want to get a int value from string "ABCD-000066123884" and formatted string "ABCD-000066000880"。
|
|
|
|
|
if your string format is constant to have a format like this "ABCD-0000000000", try to split your string to string array then get the second index value and lastly do your Int32.TryParse thing.
string[] myString = ("ABCD-000066123884").Split('-');<br />
Int32.TryParse(myString[1],out intVar);
Happy Coding...
|
|
|
|
|
I think I know what he wants :
That means :
ABCD-000066123884 is not 66123884, but 1234.
If that is the problem, then you must write your own method to parse the string.
|
|
|
|
|
Yes , It is the problem.
|
|
|
|
|
Probably this is what you need:
static int MyOwnParser(string text, string formatter)
{
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < formatter.Length; i++ )
{
if(formatter[i] == '0')
{
stringBuilder.Append(text[i]);
}
}
return int.Parse(stringBuilder.ToString());
}
|
|
|
|
|
I was thinking in the same direction, only without the StringBuilder as intermediate result...
int result = 0;
for (int i = 0; i < formatter.Length; i++) {
if (formatter[i] == '0') {
result = result * 10 + (text[i] - '0');
}
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
This method of int32 convert to string with format,maybe can not reverse.
When the format string contains "#".
From MSDN:
#
Digit placeholder
If the value being formatted has a digit in the position where the '#' appears in the format string, then that digit is copied to the result string. Otherwise, nothing is stored in that position in the result string.
Note that this specifier never displays the '0' character if it is not a significant digit, even if '0' is the only digit in the string. It will display the '0' character if it is a significant digit in the number being displayed.
The "##" format string causes the value to be rounded to the nearest digit preceding the decimal, where rounding away from zero is always used. For example, formatting 34.5 with "##" would result in the value 35.
|
|
|
|
|
how to Know the language of the writing that had been made
thanks
|
|
|
|
|
Pardon?! Please explain in details
|
|
|
|