473,569 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Convert Text Dates to Date format

NeoPa
32,564 Recognized Expert Moderator MVP
This thread is a response to a very popular thread (How to convert Text dates to Date format?) which is locked down now so I thought I'd reply separately. This should be considered as a continuation of the topic where, hopefully, I can clarify any confusion.

Always bear in mind that date values and date literals are completely different animals. Literal DateTimes and Their Delimiters (#) may help with the understanding.

A date value, with or without the date or time portions, is stored internally (In most systems.) as a double-precision count of the number of days past a certain point in history. Whenever you see a date/time value displayed it is almost certainly after the value has been formatted. It's really very important to understand this point.

A date literal, as you may find in a value used within SQL for instance, will be a formatted string. As you'll see from the linked article above the formatting can vary considerably - even within SQL - but it's always a string.

Most of the problems I've seen questions about can all boil down to the simple confusion of the person with the problem treating something as one type (Double or String) when they really should have treated it as the other. IE. Get that right in your head and you're very unlikely to experience problems.

From a date value (Double) you can select one part and exclude the other by using two of the VBA functions (The library VBA as opposed to the language.) :
Expand|Select|Wrap|Line Numbers
  1. DateValue()
  2. TimeValue()
These each return just the part specified in the name.
Oct 23 '21 #1
4 20659
svtsolutionllc
2 New Member
You can convert text date to date format by using following function procedures.
Expand|Select|Wrap|Line Numbers
  1. DateValue()
  2. TimeValue()
Nov 3 '21 #2
NeoPa
32,564 Recognized Expert Moderator MVP
Why would you send a reply that is only a small part of the answer when the question has already been dealt with in full?

I take time to read what's been added but nothing whatsoever has been added. Just a small part copied - and even that had to be corrected.
Nov 4 '21 #3
LeoDEL
1 New Member
Using the DATEVALUE function is a basic method to convert a date into an actual date which is stored as a text.
Nov 9 '21 #4
NeoPa
32,564 Recognized Expert Moderator MVP
Hi Leo.

While you haven't added anything to the discussion that wasn't already there and properly described in the original article, you have managed to introduce some confusion in what you've posted. Let me see if I can clarify that so that nobody gets confused. Generally speaking of course, it's better to read the original before replying and only reply if you have something to add that may be helpful.

While code that uses the DateValue() function in VBA will return a date value if a string value is passed, it isn't the fact of calling the function which ensures the string value is converted to a date value. It does have input in as much as the parameter expected being specified as Date/Time ensures the compiler will recognise that the value expected is a Date/Time (Technically a Date type but in VBA this handles both dates & times of course.) and therefore do a conversion for you before the value is passed to the function.

Essentially the DateValue() function will be passed a value that has already been converted to Date/Time if the value passed is capable of being interpreted that way. It will not even have any way of determining that the original value was different from what it was passed.

VBA does a lot of conversions for you automatically. It's a concept of the language.
Nov 16 '21 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
32395
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 bind of DB2 utility packages to use ISO, USA or some other format. What is to be done in AS/400 to achieve the same? TIA.
5
129492
by: deko | last post by:
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() AS dtmApptDate FROM tblAppointments
7
5142
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
14483
by: megala | last post by:
Hi How to convert a string "11022005" to a specific date format-02/11/2005
0
1966
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 binded to a C# aspx page. I want to take one custom date XML element as input and produce the RFC 822 equivalent. Any ideas how this can be...
3
3572
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 gives 31/12/1899 and CVDate() which returns empty. I need the format displayed by IsDate() but I need the correct one ofcourse :) Greetz Twanne
3
4326
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 then on the other button click that selected should get converted into csv. Please help.
1
1738
by: Gana st | last post by:
How to convert string (date stored as string) to date and how do i add 1 year?
8
7834
by: DAHLKA | last post by:
I have a legacy date stored in a text field in DDMMMYYYY format that I need to convert to a date in MM/DD/YYYY format in Access. Example, convert text stored as 10JAN2017 to date in 01/10/2017 format. How?
6
1549
by: jdusn1978 | last post by:
Goal: Convert text to date in a query and show only dates that are older than 60 days from Date() I’ve searched the site and nothing quite matches what I’m looking for, at least in a way I can comprehend. I can read VBA and SQL at the about the level of a very skilled orangutan. I’m automating an Excel process using Access. I import...
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7970
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.