HI guys how can i insert todays date in my query,my query is as follows:

myString = @"INSERT INTO wordTbl(word,text,date)  Values('" + (string)row["word"] + "','"+richTextBox1.Text+"','"+DateTime.Now.ToString()+"')";

Recommended Answers

All 9 Replies

I dont know querys but C# has a DateTime.Now method that might help?

can i store this in a variable and then i ll be able to pass it in query

Why don't you tell us what you're trying to do and we can tell you how to go about it. You must have to post your problem here.

DateTime.Now.ToString("yyyyMMdd hh:mm:ss:fff")

Take a timer contor,label on your form & write following code on timer

label1.Text = DateTime.Noe.ToString();
It cna store and display the current date time.

sorry for any misunderstanding guys.What i am trying to do is to add a word ina databse and the date that word was added to database. I am trying to write a query to input the word and current date with it.my query looks like this...

myString = @"INSERT INTO wordTbl(word,text,date)  Values('" + (string)row["word"] + "','"+richTextBox1.Text+"','"+DateTime.Now.ToString()+"')";
myString = @"INSERT INTO wordTbl(word,text,date)  Values('" + (string)row["word"] + "','"+richTextBox1.Text+"','"+DateTime.Now.ToString("yyyyMMdd hh:mm:ss:fff")+"')";

Thanks That worked.Thanks a lot finito.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.