-
October 23rd, 2017, 02:09 PM
#1
Convert String to DateTime for SQL Server Insert
I have a string that looks like 2017:10:08 13:01:14 and simply need to convert it into an acceptable DateTime format for inserting into a SQL Server field of type datetime.
I would prefer to use something simple and flexible like
Code:
DateTime.Parse(datevar)
...but that is not working. I have also tried
Code:
DateTime.ParseExact(datevar, "yyyy:MM:dd HH:mm:tt", Nothing)
which is not working either. Any help you can provide is appreciated!
-
October 23rd, 2017, 02:59 PM
#2
Re: Convert String to DateTime for SQL Server Insert
Not sure if this additional code will be helpful...
Code:
Dim img As Image = Image.FromFile(FileName)
Dim dateTaken As String
Dim dateforinsert As DateTime
Dim pitem As PropertyItem
If img.PropertyIdList.Contains(DATE_TAKEN) Then
pitem = img.GetPropertyItem(DATE_TAKEN)
dateTaken = Encoding.UTF8.GetString(pitem.Value, 0, pitem.Value.Length)
dateforinsert = DateTime.ParseExact(dateTaken, "yyyy:MM:dd HH:mm:ss", Nothing)
Else
dateTaken = Nothing
End If
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|