Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GETDATE() SQL

Status
Not open for further replies.

jward

MIS
Dec 21, 2000
57
US
Using "Select GetDate()" how can I pass this information to a label on a form. What is the process to get the information. Any code examples would be helpful

 
are you expecting the date on the db server to be different than the local machine?

If not then try:

TextBox1.Text = Now()
or
TextBox1.Text = Now.ToShortDateString

Kris
 
I need to compare the current "server" date with a date in a date field in my SQL Database. I can insert the server's Date into the database I just can't seem to do a compare and return the results of that compare to my application.
 
Did you make a command object with your sql, and also, what did you do for your SQL. Try something like "SELECT getdate() as 'Anything' from AnyTable."

Then you say "Text1.Text = yourCommand.ExecuteScalar".
 
What I've done is created a Table with all the information I want to store in it, 1 Column has a formula on it (dateadd(day,15,convert(char(10),getdate(),101))) so this column is populated when a new record is added. Now I want to query this record against the servers date and put the date difference on a label in my application. So the above puts a date in that is 15 days from the date the record was added, I want to display this in my application. I don't want to compare the date against the client date in case the date on the client PC is incorrect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top