Peter Faase Member Licensed User Longtime User Aug 25, 2013 #1 Howdy, I am completly new and i am sure i am missing something but i really can't get my head around it. I would apprieciate a little help on this matter I connect my app to a MySql database, so far so good. All works fine (thanks Andre ;-) ) but now here's the point i struggle with: I have a label on my screen and want to fill that with a a date out of the database, i use the following command: lblGebDatum.Text=m.Get("gebdatum") I get a nice string back as: "1908-08-27" and that one is put on the label.. But i don't want it this way i want is formatted to the Dutch date format so: 27-08-1908. I allready tried the use of Datetime. datetime.DateParse (m.Get("gebdatum") but that doesn't work for me. Any help is welcome! Cheers, Peter
Howdy, I am completly new and i am sure i am missing something but i really can't get my head around it. I would apprieciate a little help on this matter I connect my app to a MySql database, so far so good. All works fine (thanks Andre ;-) ) but now here's the point i struggle with: I have a label on my screen and want to fill that with a a date out of the database, i use the following command: lblGebDatum.Text=m.Get("gebdatum") I get a nice string back as: "1908-08-27" and that one is put on the label.. But i don't want it this way i want is formatted to the Dutch date format so: 27-08-1908. I allready tried the use of Datetime. datetime.DateParse (m.Get("gebdatum") but that doesn't work for me. Any help is welcome! Cheers, Peter
M Mahares Expert Licensed User Longtime User Aug 25, 2013 #2 You can do something like this: Code: Copy Dim strDate As String="1908-08-27" Dim lngDate As Long DateTime.dateformat="yyyy-MM-dd" lngDate= DateTime.DateParse(strDate) DateTime.dateformat="dd-MM-yyyy" lblDate.Text=DateTime.Date(lngDate) Msgbox(lblDate.text,"") 'Displays 27-08-1908 And if you do not want to make use of the DateTime function here is another method: Code: Copy Dim strDateArray() As String Dim strDate As String="1908-08-27" strDateArray=Regex.Split("-",strDate) lblDate.Text=strDateArray(2) & "-" & strDateArray(1) & "-" & strDateArray(0) Msgbox(lblDate.Text,"") 'Displays 27-08-1908 Last edited: Aug 25, 2013 Upvote 0
You can do something like this: Code: Copy Dim strDate As String="1908-08-27" Dim lngDate As Long DateTime.dateformat="yyyy-MM-dd" lngDate= DateTime.DateParse(strDate) DateTime.dateformat="dd-MM-yyyy" lblDate.Text=DateTime.Date(lngDate) Msgbox(lblDate.text,"") 'Displays 27-08-1908 And if you do not want to make use of the DateTime function here is another method: Code: Copy Dim strDateArray() As String Dim strDate As String="1908-08-27" strDateArray=Regex.Split("-",strDate) lblDate.Text=strDateArray(2) & "-" & strDateArray(1) & "-" & strDateArray(0) Msgbox(lblDate.Text,"") 'Displays 27-08-1908
mangojack Expert Licensed User Longtime User Aug 25, 2013 #3 Try this .. might not be most efficient way .. Code: Copy Dim MyDate As Long 'store working date as ticks DateTime.DateFormat = "yyyy-mm-d" MyDate = DateTime.DateParse("1908-08-27") Log (MyDate) DateTime.DateFormat = "d-mm-yyyy" Log(DateTime.Date(MyDate)) Cheers mj Upvote 0
Try this .. might not be most efficient way .. Code: Copy Dim MyDate As Long 'store working date as ticks DateTime.DateFormat = "yyyy-mm-d" MyDate = DateTime.DateParse("1908-08-27") Log (MyDate) DateTime.DateFormat = "d-mm-yyyy" Log(DateTime.Date(MyDate)) Cheers mj
Peter Faase Member Licensed User Longtime User Aug 25, 2013 #4 Thanks guys, this makes sense to me and it works ;-) Cheers, Peter Upvote 0