473,395 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to convert Text dates to Date format?

After importing text date fields, the dates look like this:

12/31/2003 8:00:00 AM

I'm having trouble working with these dates with Date(), Now(), etc, --
does not seem to match these dates.
I've tried converting them in a query like this:

SELECT CDate([ApptDate]) AS dtmApptDate
FROM tblAppointments

But that does not seem to help...
I'm only interested in the "date" part of the date (e.g. 12/31/03) and don't
need the time. Is there some simple text-to-date conversion I can perform
to discard all but the date portion?

Thanks in advance...
Nov 12 '05 #1
5 129465
How about this ...

SELECT Format(CDate([ApptDate]), "mm/dd/yyyy") FROM ...

or if ApptDate is already a valid date, just use the FORMAT function
without the CDate() function at all

--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com
"deko" <dj****@hotmail.com> wrote in message news:Y%*******************@newssvr29.news.prodigy. com...
After importing text date fields, the dates look like this:

12/31/2003 8:00:00 AM

I'm having trouble working with these dates with Date(), Now(), etc, --
does not seem to match these dates.
I've tried converting them in a query like this:

SELECT CDate([ApptDate]) AS dtmApptDate
FROM tblAppointments

But that does not seem to help...
I'm only interested in the "date" part of the date (e.g. 12/31/03) and don't
need the time. Is there some simple text-to-date conversion I can perform
to discard all but the date portion?

Thanks in advance...

Nov 12 '05 #2
Try
Format(CDate(ApptDate), "Medium Date")

Phil

"deko" <dj****@hotmail.com> wrote in message
news:Y%*******************@newssvr29.news.prodigy. com...
After importing text date fields, the dates look like this:

12/31/2003 8:00:00 AM

I'm having trouble working with these dates with Date(), Now(), etc, --
does not seem to match these dates.
I've tried converting them in a query like this:

SELECT CDate([ApptDate]) AS dtmApptDate
FROM tblAppointments

But that does not seem to help...
I'm only interested in the "date" part of the date (e.g. 12/31/03) and don't need the time. Is there some simple text-to-date conversion I can perform
to discard all but the date portion?

Thanks in advance...

Nov 12 '05 #3
Thanks Danny and Pil for the replies!

I'm still experimenting with the FORMAT trick, but also found this to be
helpful when doing the import:

rst!ApptDate = DateValue(varAppt.Start)

so far so good...

"deko" <dj****@hotmail.com> wrote in message
news:Y%*******************@newssvr29.news.prodigy. com...
After importing text date fields, the dates look like this:

12/31/2003 8:00:00 AM

I'm having trouble working with these dates with Date(), Now(), etc, --
does not seem to match these dates.
I've tried converting them in a query like this:

SELECT CDate([ApptDate]) AS dtmApptDate
FROM tblAppointments

But that does not seem to help...
I'm only interested in the "date" part of the date (e.g. 12/31/03) and don't need the time. Is there some simple text-to-date conversion I can perform
to discard all but the date portion?

Thanks in advance...

Nov 12 '05 #4
sorry, Phil...

"deko" <dj****@hotmail.com> wrote in message
news:wS*******************@newssvr25.news.prodigy. com...
Thanks Danny and Pil for the replies!

I'm still experimenting with the FORMAT trick, but also found this to be
helpful when doing the import:

rst!ApptDate = DateValue(varAppt.Start)

so far so good...

"deko" <dj****@hotmail.com> wrote in message
news:Y%*******************@newssvr29.news.prodigy. com...
After importing text date fields, the dates look like this:

12/31/2003 8:00:00 AM

I'm having trouble working with these dates with Date(), Now(), etc, --
does not seem to match these dates.
I've tried converting them in a query like this:

SELECT CDate([ApptDate]) AS dtmApptDate
FROM tblAppointments

But that does not seem to help...
I'm only interested in the "date" part of the date (e.g. 12/31/03) and

don't
need the time. Is there some simple text-to-date conversion I can perform to discard all but the date portion?

Thanks in advance...


Nov 12 '05 #5
I ended up doing the conversion on import like this:

rst.AddNew
rst!ApptDate = DateValue(CDate(varAppt.Start))
rst.Update

seems to work nicely
"Chuck Grimsby" <c.*******@worldnet.att.net.invalid> wrote in message
news:4n********************************@4ax.com...

Personally, I'd use CVDate rather then CDate. CVDate handles "bad"
dates more often.

But then again, of late I've been using DateSerial (and TimeSerial
when needed) for conversions, so I can more accurately control the
conversion.
On Mon, 8 Dec 2003 08:51:19 -0700, "Danny J. Lesandrini"
<dl*********@hotmail.com> wrote:
How about this ...
SELECT Format(CDate([ApptDate]), "mm/dd/yyyy") FROM ...
or if ApptDate is already a valid date, just use the FORMAT function
without the CDate() function at all

--
Why Do 24-hour Stores Have Locks On The Doors?

Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ggnanaraj | last post by:
In AS/400, have a table that has a character field defined. This has to be converted to date format of YYYY-MM-DD. The sample character data is as follows: 02/05/2005. In UDB, you can do a...
7
by: Nimmy | last post by:
Hi, I have a file which has different dates, I want to scanf them as CHAR and convert them to DATE format, how can I do this? Thanks
2
by: megala | last post by:
Hi How to convert a string "11022005" to a specific date format-02/11/2005
0
by: stevag | last post by:
I want to convert a custom date format of the type DD/MM/YYYY into the RFC 822 date format in order to use it for RSS feeds. I want to do this transformation into an XSLT transformation which is...
8
by: John Wildes | last post by:
Hello all I'm going to try and be brief with my question, please tell me if I have the wrong group. We are querying transaction data from a DB3 database application. The dates are stored as...
3
by: Twanne | last post by:
Hi, I've got a field in textformat with a date that looks like this: 2005-01-03 22:43:19.65 Now I need to move this field to another field in date format. So far I tried to use IsDate() that...
3
by: ITCraze | last post by:
Thank you debasisdas for replying. But u know I have t convert the txt file into csv through C# code.My application requires that I have to select one text file from the Browse and...
10
by: veer | last post by:
Hi I have a probleum in vconverting a string value into date in vb.net e.g str="31.12.2005" i want to convert it into date format like "mm/dd/yyyy" i use CDATE function for it but every time...
5
by: Artie | last post by:
Hi, I have a date field stored as an INT and need to convert to a date format mm/dd/yyyy. I'm having trouble determining what the starting date is. min(date) = 730395 max(date) = 733189 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.