Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reduce this date trimming code

Posted on 2006-07-07
4
Medium Priority
?
240 Views
Last Modified: 2010-04-23
There is always better and easier ways to do things and I think this code is probably proof.

What happens is I pull a date from a dataset and they are always formatted the same like this.

7/8/2005 12:00 PM
1/2/2004 12:00 PM
12/12/2006 12:00 PM

The 12:00 PM is always there and this is because the said datatable is pulled from a FOXPRO source with no time, so the 12:00 PM is a NULL time I guess. So before I push this into an SQL database I need to pull these 12:00 PM times out and push in a time field. Now this code does work perfectly but seems a little long.

Dim my_date As String = drfox("d_date").ToString
Dim my_time As String = drfox("d_time").ToString
my_date = my_date.TrimEnd("A"c, "P"c, "M"c)
my_date = my_date.Trim()
my_date = my_date.TrimEnd("1"c, "2"c, "0"c, ":"c)
my_date = my_date.Trim()
my_date = my_date & " " & my_time
drfox("d_date") = test
0
Comment
Question by:ParanoidOne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 17059490
Try this:

   Dim tempDate As Date = CDate(drfox("d_date").ToString()).ToString() & " " & drfox("d_time").ToString)
   drfox("d_date") = tempDate.ToString()

Bob
   
0
 

Author Comment

by:ParanoidOne
ID: 17060058
I think there was a small typo.

CDate((drfox

But other than that it worked beautiful !!!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17060218
I was coding in the comment block ;)

Bob
0
 

Author Comment

by:ParanoidOne
ID: 17060276
I figured you were :) Which I doubt I will ever be able to do.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question