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 date. Show all posts
Showing posts with label date. 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();
}
Entering the current date into a cell in Microsoft Excel
Within Excel there is a method of entering a formula that will automatically enter the current date. The formula is as follows :
=Today()
It should be noted that there is one final step to show only the date as the above will return the current date AND a time that will show as zeros. In order to only show the date in the cell. Highlight the column select format and then choose 'Date'.
As soon as this final step is complete you will be left with the current date.
=Today()
It should be noted that there is one final step to show only the date as the above will return the current date AND a time that will show as zeros. In order to only show the date in the cell. Highlight the column select format and then choose 'Date'.
As soon as this final step is complete you will be left with the current date.
Subscribe to:
Posts (Atom)