Reading data set and convert date
Reading data set and convert date
Reading data set and convert date
Reading data set and convert date
Reading data set and convert date
Reading data set and convert date Reading data set and convert date Reading data set and convert date Reading data set and convert date Reading data set and convert date Reading data set and convert date Reading data set and convert date Reading data set and convert date
Reading data set and convert date Reading data set and convert date
Reading data set and convert date
Go Back  Xtreme Visual Basic Talk > > > Reading data set and convert date


Reply
 
Thread Tools Display Modes
  #1  
Old 10-06-2008, 11:52 AM
snufse's Avatar
snufse snufse is offline
Centurion
 
Join Date: Jul 2003
Location: West Palm Beach FL
Posts: 180
Default Reading data set and convert date


I am looping through a data set and inserting records into a db table. Need to cast date from dd/mm/yyy to ddmmyy. Not sure how to do this. My date field is field "myRow.Item(2)" from my data set.

Code:
For Each myRow In myAdsDataset.Tables("SalesTicketData").Rows()
myAS400InsertString = "insert into " & myAS400Library & "." & myAS400FileName & "(f1, f2, f3)" & "values (" & "'" & myRow.Item(0) & "'" & "," &   myRow.Item(1) & "," & myRow.Item(2) & ")"
myAS400OleDbCommand.Connection = myAS400OleDbConnection
myAS400OleDbCommand.CommandText = myAs400InsertString
myAS400OleDbCommand.ExecuteNonQuery()
Next
Current value of my data set:

insert into rjadevlib.f5514ar(f1, f2, f3)values ('R ',168797,10/1/2008)
Reply With Quote
  #2  
Old 10-06-2008, 02:02 PM
wayneph's Avatar
waynephReading data set and convert date wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

myRow.Item(2).ToString("ddMMyy")

You can see more about the datetime formatting with ToString here on MSDN: http://msdn.microsoft.com/en-us/library/aa326721.aspx
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
  #3  
Old 10-07-2008, 09:20 AM
snufse's Avatar
snufse snufse is offline
Centurion
 
Join Date: Jul 2003
Location: West Palm Beach FL
Posts: 180
Default

Was able to use this:

Dim myDate As Integer = Format(myRow.Item(2), "ddMMyy")
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Reading data set and convert date
Reading data set and convert date
Reading data set and convert date Reading data set and convert date
Reading data set and convert date
Reading data set and convert date
Reading data set and convert date Reading data set and convert date Reading data set and convert date Reading data set and convert date Reading data set and convert date Reading data set and convert date Reading data set and convert date
Reading data set and convert date
Reading data set and convert date
 
Reading data set and convert date
Reading data set and convert date
 
-->