You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Removing hours and minutes from date
1 view (last 30 days)
Show older comments
I have an entry
04/20/2016 00:00
I want to set it just to
04/20/2016
Please advise the steps.
22 Comments
Stephen23
on 12 Jun 2018
Edited: Stephen23
on 13 Jun 2018
Regarding your comment: https://www.mathworks.com/matlabcentral/answers/405315-removing-hours-and-minutes-from-date#comment_577922:
one datetime object is scalar, so it makes no sense to index into it. All you need to do is change its Format property.
Jan
on 12 Jun 2018
@alpedhuez: "An entry in a table" can be a variety of things. Please explain this exactly. Prefer to post some code, which creates the data.
Whenever you mention in the forum, that you get an error message, post a copy of it. We cannot read your mind or your screen. The less the readers have to guess, the faster you get a solution.
Walter Roberson
on 12 Jun 2018
We will also need to know which MATLAB release you are using.
Jan
on 13 Jun 2018
@alpeduez: Summary:
You have a file with this contents:
X,Y
1/3/09,1.00
1/5/09,0.00
1/7/09,0.00
1/9/09,14.00
1/11/09,106.00
1/13/09,116.00
1/15/09,136.00
1/17/09,109.00
1/19/09,120.00
1/21/09,115.00
- Which method do you use to import it?
- Which code do you run currently? Post the relevant part.
- Post a copy of the complete error message also.
If these information is provided, an answer will need some lines only and is most likely given after a few minutes. You are one of the top-ten askers in this forum, so I expect that you are familiar with the fact, that sharing the details of the problem helps to solve them efficiently.
Stephen23
on 13 Jun 2018
Edited: Stephen23
on 13 Jun 2018
"I meant checking when running the code."
How could MATLAB know the difference between a conflict, and you just using (accessing/redefining) a variable? What is the difference? How do you define "conflict"? Please show an example.
I don't see how it is possible for any code interpreter to know when my usage of a variable is a "conflict", or when I intentionally redefine or use that variable, unless it learns and understands what the code is doing. Any warnings along the lines of "this variable is already defined" would be pop up regularly, irritate the user, and would ultimately end up being ignored. Please explain how your concept would identify such "conflicts".
alpedhuez
on 13 Jun 2018
I just meant that it could make sense to include this type of analysis in "Warnings" section. Do not think it irritates a user when there are significant possibilities that these errors can halt the code. As a bottom line, it is not a big deal.
Rik
on 13 Jun 2018
I regularly overwrite variable like looping variables or temporary container variables. I would not like to have my m-lint full of warnings when I do, that would defeat the usefulness of the m-lint. I like to keep it green (I add the %#ok flag if I don't resolve the source of the warning). That way I can immediately spot new warnings/errors when they pop up.
I would not want to force my workflow on everybody, but I think its not too far from the intended use. I don't see how your suggestion could be implemented so that it helps you solve this issue, without making it very cumbersome to get the green flag from m-lint (without a forest of %#ok).
Stephen23
on 13 Jun 2018
Edited: Stephen23
on 13 Jun 2018
@alpedhuez: I am asking for an exact definition of what a "conflict" is. Because any code checking tool would need an exact definition of "conflict", which so far you have not given us. Simply saying "... this type of analysis" has no meaning to me, or to any interpreter, which is why I am asking you what your definition is. I am genuinely interested. I wrote about one possibility (redefining variables), but I am interested to know what you mean by a "conflict". Please help me understand what you want to classify as a "conflict":
* changing a variable's value
* changing a variable's class
* accessing a variable (main function)
* accessing a variable (nested function)
* accessing a variable (evalin, etc)
* indexing into a variable
* clearing a variable
* ... ?
And how is the interpreter supposed to know the difference between these:
- accessing a variable (a conflict)
- accessing a variable (I just want to access that variable)
??
Walter Roberson
on 13 Jun 2018
Conflicts between variables hint that you should be breaking your code up into smaller functions.
Answers (0)
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)