Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
jgibbs  
#1 Posted : Thursday, October 9, 2008 12:46:03 AM(UTC)
jgibbs

Rank: Advanced Member

Groups: Member
Joined: 9/22/2008(UTC)
Posts: 39

I'm able to pull the ExifDateTime attribute from the JPG file, but I have to insert it into a SQL 2000 database that has a datatype of "date".

How do I convert "2006:05:11 14:40:00"
To just "05/11/2006" as a date?

I have this in my upload script:

Code:
Dim theDateTaken As String = Request.Form("ExifDateTaken_" & i)


But doing:

Code:
cmdInsert.Parameters.Add("@DateTaken_" & i & "", Format(theDateTaken, "MM/dd/yyyy"))


doesn't work. Any idea? I'm still a n00b at VB and ASP.NET

Thanks

Edited by user Tuesday, October 14, 2008 5:40:46 PM(UTC)  | Reason: Not specified

Fedor  
#2 Posted : Thursday, October 9, 2008 1:34:31 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,558

Thanks: 5 times
Was thanked: 62 time(s) in 61 post(s)
Hello,

Please try to use this code:

Code:
Dim info AS New DateTimeFormatInfo()
info.ShortDatePattern = "yyyy:MM:dd HH:mm:ss"
Dim theDateTaken As DateTime = DateTime.ParseExact(Request.Form
["ExifDateTaken_" + Parent.FileIndex], "d", info)

cmdInsert.Parameters.Add("@DateTaken_" & i & "", theDateTaken)
Best regards,
Fedor Skvortsov
jgibbs  
#3 Posted : Thursday, October 9, 2008 1:58:07 AM(UTC)
jgibbs

Rank: Advanced Member

Groups: Member
Joined: 9/22/2008(UTC)
Posts: 39

Doesn't seem to work in VB, is that right?

I get: BC30002: Type 'DateTimeFormatInfo' is not defined.
Fedor  
#4 Posted : Thursday, October 9, 2008 7:17:37 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,558

Thanks: 5 times
Was thanked: 62 time(s) in 61 post(s)
Quote:
Doesn't seem to work in VB, is that right?

I get: BC30002: Type 'DateTimeFormatInfo' is not defined.


DateTimeFormatInfo is defined System.Globalization namespace. So either import this namespace or specify full class name:

Code:
Dim info AS New System.Globalization.DateTimeFormatInfo()
Best regards,
Fedor Skvortsov
jgibbs  
#5 Posted : Tuesday, October 14, 2008 3:03:48 AM(UTC)
jgibbs

Rank: Advanced Member

Groups: Member
Joined: 9/22/2008(UTC)
Posts: 39

This just doesn't seem to work still. I get something saying paramter "s" is not defined:

Dim info AS New System.Globalization.DateTimeFormatInfo()
info.ShortDatePattern = "yyyy:MM:dd HH:mm:ss"
Dim theDateTaken As DateTime = DateTime.ParseExact(Request.Form("ExifDateTaken_" & i), "d", info)
Dmitry  
#6 Posted : Sunday, October 19, 2008 9:50:57 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

Please, try this sample:
Code:

Dim exifDateTime As String = "2006:05:11 14:40:00"
Dim exifDateTimeFormat As String = "yyyy:MM:dd HH:mm:ss"
Dim dateTime As System.DateTime = System.DateTime.ParseExact(exifDateTime, _
  exifDateTimeFormat, System.Globalization.CultureInfo.InvariantCulture)
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.