File Exchange

image thumbnail

Find the day from a date

version (1.24 KB) by Jitendra Dalei
Enter any date and know the day of the week.

1 Download

Updated 22 Feb 2013

View License

Enter any date and know the day of the week.

Cite As

Jitendra Dalei (2021). Find the day from a date (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Jitendra Dalei

I'm a beginner in Matlab. Learnt a lot from your comment and I'll try to improve my coding knowledge.
Thanks for your feedback.


This is a script, which needs INPUT to define the data and therefore less usable than a function. The magic and brute clearing "clc, clear all, close all" destroys all former work of the users, when they try to run the code. I strongly recommend to omit such clearing, because it is not useful at all.
The Matlab function WEEKDAY finds the day of the week also.
The code can be much more compact using something like this:
Verb = {'was', 'is', 'will be'};
fprintf('The day %s %s\n', ...
Verb{2 + sign(n - datenum(date))}, Days{d})
But a SWITCH block or at least some ELSEIF would be an improvement also.

A script with the brute clearing header, INPUT, and a large redundant code is neither useful for productive work nor for educational purposes. The code works, but who can or will use this?

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!