You should use datetime type variables instead of strings.
martonx
Junior Poster in Training
51 posts since May 2008
Reputation Points: 10
Solved Threads: 8
hi..I'm just a newbie programmer who needs some help. I'm trying to enter a date and save it in a mysql database. however the format in mysql is yyyy-mm-dd and the format in vb.net is mm-dd-yyyy. how can i format the date in vb in order to successfully enter it in the database?
ive tried using this code
dim mydate as string
mydate = now.year & "-" & now.month & "-".now.day
and it works but the problem is I'm trying to use the date in order to get the difference
between two given months using the DateDiff function but it wont accept it since the variable mydate is a string and not a date type
how can I fix this problem? thanks
First, store your date as Date/Time in your Database
row("mydate") = Format(Now, "General Date") 'mydate is a Date/Time Format in your MySQL Database
Then get Them and place it in your variable like below
Dim date1 As Date
Dim date2 As Date
Me.Textbox1.Text = DateDiff(DateInterval.Day, Date1,Date2)
c0deFr3aK
Junior Poster in Training
71 posts since Mar 2009
Reputation Points: 11
Solved Threads: 10