PC Review


Reply
Thread Tools Rate Thread

Date Convert

 
 
=?Utf-8?B?Q2hyaXM=?=
Guest
Posts: n/a
 
      10th Apr 2006
I would like to convert a column to a date format and delete the first colum
when I import it here is the code I have for when I am importing this file

Example data

* 20051231 0.0442 0.044 0.0431

Result I would like to see

12/31/2005 0.0442 0.044 0.0431


'This would import the Current Month Data
Private Sub cmdImport_Click()
On Error GoTo ErrorCheck


varFilename = Me.txtInputFile
If IsNull(varFilename) Then
MsgBox "You must enter an input filename.", vbExclamation, " "
Me.txtInputFile.SetFocus
Exit Sub
End If

DoCmd.TransferText acImportDelim, Master, "Rate_Table_LIBOR_Swap",
varFilename, True


ErrorCheck:
Select Case Err.Number
Case 7874 'Import file not there to delete
Resume Next
Case Else
MsgBox "Error " & Err.Number & " - " & Err.Description
Exit Sub
End Select

End Sub

Thanks

Chirs
 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      11th Apr 2006
Hi,
I think you can first import file as is in a temporary table, then make a
VBA function to convert date to proper format, and then append data to your
main table

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

"Chris" <(E-Mail Removed)> wrote in message
news:A612BAC5-B145-438D-96AD-(E-Mail Removed)...
>I would like to convert a column to a date format and delete the first
>colum
> when I import it here is the code I have for when I am importing this file
>
> Example data
>
> * 20051231 0.0442 0.044 0.0431
>
> Result I would like to see
>
> 12/31/2005 0.0442 0.044 0.0431
>
>
> 'This would import the Current Month Data
> Private Sub cmdImport_Click()
> On Error GoTo ErrorCheck
>
>
> varFilename = Me.txtInputFile
> If IsNull(varFilename) Then
> MsgBox "You must enter an input filename.", vbExclamation, " "
> Me.txtInputFile.SetFocus
> Exit Sub
> End If
>
> DoCmd.TransferText acImportDelim, Master, "Rate_Table_LIBOR_Swap",
> varFilename, True
>
>
> ErrorCheck:
> Select Case Err.Number
> Case 7874 'Import file not there to delete
> Resume Next
> Case Else
> MsgBox "Error " & Err.Number & " - " & Err.Description
> Exit Sub
> End Select
>
> End Sub
>
> Thanks
>
> Chirs


 
Reply With Quote
 
=?Utf-8?B?Q2hyaXM=?=
Guest
Posts: n/a
 
      11th Apr 2006
Thanks Alex,
But how do I write that VBA code


"Alex Dybenko" wrote:

> Hi,
> I think you can first import file as is in a temporary table, then make a
> VBA function to convert date to proper format, and then append data to your
> main table
>
> --
> Best regards,
> ___________
> Alex Dybenko (MVP)
> http://alexdyb.blogspot.com
> http://www.PointLtd.com
>
> "Chris" <(E-Mail Removed)> wrote in message
> news:A612BAC5-B145-438D-96AD-(E-Mail Removed)...
> >I would like to convert a column to a date format and delete the first
> >colum
> > when I import it here is the code I have for when I am importing this file
> >
> > Example data
> >
> > * 20051231 0.0442 0.044 0.0431
> >
> > Result I would like to see
> >
> > 12/31/2005 0.0442 0.044 0.0431
> >
> >
> > 'This would import the Current Month Data
> > Private Sub cmdImport_Click()
> > On Error GoTo ErrorCheck
> >
> >
> > varFilename = Me.txtInputFile
> > If IsNull(varFilename) Then
> > MsgBox "You must enter an input filename.", vbExclamation, " "
> > Me.txtInputFile.SetFocus
> > Exit Sub
> > End If
> >
> > DoCmd.TransferText acImportDelim, Master, "Rate_Table_LIBOR_Swap",
> > varFilename, True
> >
> >
> > ErrorCheck:
> > Select Case Err.Number
> > Case 7874 'Import file not there to delete
> > Resume Next
> > Case Else
> > MsgBox "Error " & Err.Number & " - " & Err.Description
> > Exit Sub
> > End Select
> >
> > End Sub
> >
> > Thanks
> >
> > Chirs

>
>

 
Reply With Quote
 
John Spencer
Guest
Posts: n/a
 
      11th Apr 2006
If you are asking how to convert the string to a date field, you could try

DateValue(Format([TheCurrentString],"@@@@/@@/@@"))

That should change the string into a date field assuming the string is in
yyyymmdd format.


"Chris" <(E-Mail Removed)> wrote in message
news:ADDCCF43-B938-4380-8E80-(E-Mail Removed)...
> Thanks Alex,
> But how do I write that VBA code
>
>
> "Alex Dybenko" wrote:
>
>> Hi,
>> I think you can first import file as is in a temporary table, then make a
>> VBA function to convert date to proper format, and then append data to
>> your
>> main table
>>
>> --
>> Best regards,
>> ___________
>> Alex Dybenko (MVP)
>> http://alexdyb.blogspot.com
>> http://www.PointLtd.com
>>
>> "Chris" <(E-Mail Removed)> wrote in message
>> news:A612BAC5-B145-438D-96AD-(E-Mail Removed)...
>> >I would like to convert a column to a date format and delete the first
>> >colum
>> > when I import it here is the code I have for when I am importing this
>> > file
>> >
>> > Example data
>> >
>> > * 20051231 0.0442 0.044 0.0431
>> >
>> > Result I would like to see
>> >
>> > 12/31/2005 0.0442 0.044 0.0431
>> >
>> >
>> > 'This would import the Current Month Data
>> > Private Sub cmdImport_Click()
>> > On Error GoTo ErrorCheck
>> >
>> >
>> > varFilename = Me.txtInputFile
>> > If IsNull(varFilename) Then
>> > MsgBox "You must enter an input filename.", vbExclamation, " "
>> > Me.txtInputFile.SetFocus
>> > Exit Sub
>> > End If
>> >
>> > DoCmd.TransferText acImportDelim, Master, "Rate_Table_LIBOR_Swap",
>> > varFilename, True
>> >
>> >
>> > ErrorCheck:
>> > Select Case Err.Number
>> > Case 7874 'Import file not there to delete
>> > Resume Next
>> > Case Else
>> > MsgBox "Error " & Err.Number & " - " & Err.Description
>> > Exit Sub
>> > End Select
>> >
>> > End Sub
>> >
>> > Thanks
>> >
>> > Chirs

>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert date (m/dd/yyyy) in text format into an excel recognised date Rob P Microsoft Excel Programming 3 30th Apr 2010 12:40 AM
Convert a julian gregorian date code into a regular date =?Utf-8?B?Um9iZXJ0?= Microsoft Excel Worksheet Functions 3 13th Jun 2006 07:03 PM
How to convert normal date to Julian date upto milliseconds precision Rajat Microsoft C# .NET 2 21st Mar 2006 06:06 AM
How to Convert Days(Text field) into Date By giving the start date FA Microsoft Access Forms 3 2nd Dec 2005 08:26 PM
How to convert user-defined custom format date string to date value abcabcabc Microsoft VB .NET 1 19th Aug 2005 12:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:15 AM.