There may be times where you will need to insert the current date and time into a database i.e. to record when a transaction has taken place. The command to display this timestamp is as follows :
select getdate() 'Current Date'
If you type this into query analyser you will get the current date and time in a column entitled 'Current Date'.
Showing posts with label time. Show all posts
Showing posts with label time. Show all posts
Sunday, 27 September 2009
Get current date and time using C#
In this example, the date and time will be written to 'label1' when 'button3' is pressed.
private void button3_Click(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();
}
private void button3_Click(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();
}
Subscribe to:
Posts (Atom)