Android Question DateTime

Peekay

Active Member
Licensed User
Longtime User
How do I get the date and time (now) in the correct format for insertion into a datetime field in Sql Server?
Thanks
PK
 

Peekay

Active Member
Licensed User
Longtime User
This code does not work: (can you please help):

date time:
Dim ThisDateTime As Long
DateTime.DateFormat="dd-MMM-yy HH:mm"
ThisDateTime = DateTime.TimeParse(DateTime.Now)
Dim cmd As DBcommand = CreateCommand("sendmessagefromsite",Array(ThisDateTime, AndroidID, Message))

java.text.ParseException: Unparseable date: "1594278402264"
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
B4X:
    DateTime.DateFormat = "yyyy-MM-dd"
    DateTime.TimeFormat = "HH:mm:ss"
    Dim ThisDateTime As Long = DateTime.Now
    Dim strDateTime As String = DateTime.Date(ThisDateTime) & " " & DateTime.Time(ThisDateTime)
    Log(strDateTime)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Yes, MS Sql Server. It is defined as datetime
B4X:
Dim ThisDateTime As String
    DateTime.DateFormat="yyyy-MM-dd HH:mm:ss"
    ThisDateTime = DateTime.date(DateTime.Now)
    Log(ThisDateTime)  'displays: 2020-07-09 07:36:24  of course current
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…