|
How to convert with DateTime.ToString() method given date to yyyy\MM\dd format?
e.g. "2011\06\17"
I would not like to use String.Format(@"{0:D4}\{1:D2}\{2:D2}")
Чесноков
|
|
|
|
|
|
DateTime.ToString(@"yyyy\MM\dd");
|
|
|
|
|
Eraser_stp wrote: DateTime.ToString(@"yyyy\MM\dd");
This code will not work.
If you have this string date = DateTime.Now.ToString(@"yyyy\MM\dd"); again wrong format because you will get this result 2011M6d17
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
My bad. Thanks for pointing and correct answer.
|
|
|
|
|
You can try this string dateformat = DateTime.Now.ToString(@"yyyy\\MM\\dd").Replace("\\",@"\");
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
The .Replace is bothering me because "\\" is the same as @"\".
Maybe you meant @"\\" instead of "\\".
|
|
|
|
|
I released that isn't necessary to use Replace so just using @"yyyy\\MM\\dd" will give correct format 2011\06\17
Thanks for correcting me
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
modified on Friday, June 17, 2011 6:07 AM
|
|
|
|
|
yes, thanks, that one works
Чесноков
|
|
|
|
|
No problem.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
|
Thanks
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
|
Good article
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
I'm having a mind blank right now, and I have googled for the answer, I can seem to come up with it.
as an example;
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;User Id=admin;Password=;
The source "database" will stay the same, the location may change. I think I did it on a project where it was "*\new folder\mydatabase.mdb" for the source, but I can't think of it off hand (nor find).
Anyone come across this? Is this the correct forum?
Thanks.
/////////////////
Groucho Marx
Those are my principles, if you don't like them… I have others.
|
|
|
|
|
Try this .\new folder\mydatabase.mdb
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
That's the one thanks for putting me out my misery.
/////////////////
Groucho Marx
Those are my principles, if you don't like them… I have others.
|
|
|
|
|
You are welcome.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Hello!, well that is the question i remember fixing this in MFC returning a false in the initdialog method, but how to do this in C#?
|
|
|
|
|
Override ShowWithoutActivation in the non-modal form:
protected override bool ShowWithoutActivation
{
get { return true; }
}
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
This made the job, just some info for anyone else, using this with topmost property to true will not work, i think this is a bug on windows forms
|
|
|
|
|
Hello everyone,
I've made a multithread data base application, which is collecting data from multiple data bases from different threads and then process it and notifies the result on GUI. I've made a console which is just a big text box. Now, my question is that what is the best way to update a single GUI component from multiple threads. So far, I've made class called class IOConsole which constains a variable called static Queue(String message) and a method public static println(string str) and then I've added a background worker in GUI thread which keep looping and checks if queque is empty or not and if not empty then it pop the string and print it on the GUI. To me its does't look very nice approach, not sure if it might be. But could I get some suggestion about how can I achieve this most efficiently.
Thanks,
Shivam Kalra
|
|
|
|
|
why not just use begininvoke or invoke? this is executed in the main thread always, or even using windows messages, or there is even invoke required way since .NET 2
the invoke way can be something like this, using anonymous method
string nextText = "qwe";
this.Invoke( (MethodInvoker)delegate {
oneLabel.Text = nextText;
}
);
|
|
|
|
|
The right idea, but it's generally better to have the updater fire events and not be tightly linked in to the UI class. E.g.
class DatabaseUpdater {
event EventHandler<UpdateEventArgs> Update;
void ThreadMethod() {
while(true){
if(thereWasAnUpdate && Update != null){
Update(this, new UpdateEventArgs(updatedTable, key, Value);
}
}
}
}
class MainForm {
List<DatabaseUpdater> updaters;
MainForm(){
foreach(DatabaseUpdater updater in updaters)
updater.Update += DatabaseUpdated;
}
void DatabaseUpdated(object sender, UpdateEventArgs e){
this.Invoke((MethodInvoker) delegate { myTextBox.Text += e.UpdatedTable + "\n"; });
}
}
|
|
|
|
|
Hi, thanks for the reply. Will this code make sure that even if I invoke it through multiple threads..may be 5 threads then will be able to print all 5 of them on the console text box? And if "yes" then could you put more light on how it does that? I thought code should have been more complicated but it looks just one sentence thing?
|
|
|
|