[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Reduce this date trimming code

Posted on 2006-07-07
4
Medium Priority
?
242 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

829 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