Showing Current date in A text box

abhi2823

Active member
Joined
Sep 8, 2007
Messages
32
Programming Experience
1-3
Hi all
I am using vb 2005 and mysql as backend and I have a form in which I have to show the current date in a text box and then save it in mysql table
How I show the current date and time in a text box and then insert the data in mysql table
 
to show current time and date
tssDate.Text = Format(DateValue(Now), "dd-MMMM-yyyy") & " " & Format(TimeValue(Now))
 
to show current time and date
tssDate.Text = Format(DateValue(Now), "dd-MMMM-yyyy") & " " & Format(TimeValue(Now))
You shouldn't use those legacy functions, Date data type have convenient methods available that is optimized to format date, and also makes the code readable and OOP conformant. Better examples:
VB.NET:
        Label1.Text = Date.Now.ToLongDateString
        Label2.Text = Date.Now.ToShortTimeString
        Label3.Text = Date.Now.Date.ToString
        Label4.Text = Date.Now.ToString("MM-yyyy")

Hi all
I am using vb 2005 and mysql as backend and I have a form in which I have to show the current date in a text box and then save it in mysql table
How I show the current date and time in a text box and then insert the data in mysql table
Instead of converting the date to string and save the string in DB when you really want to store date information, you should store the Date value in a Date type column. This also give you opportunities later to operate on Date information both at backend and frontend without use of problematic string parsing and possible culture indifferences.

VB.NET-MySQL Tutorials
 
Back
Top