File Exchange

image thumbnail


version (3.42 KB) by Elmar Tarajan
UIGETDATE displays a dialog box in form of a calendar.


Updated 19 Aug 2005

View License

UIGETDATE date selection dialog box
T = UIGETDATE(D) displays a dialog box in form of a calendar

UIGETDATE expects serial date number or standard MATLAB Date
format (see DATESTR) as input data und returns serial date number
for the selected date and time.

UIGETDATE by itself uses the current date and time as input data

t = datestr( uigetdate('16-Aug-1974 03:00') )

See also datevec, datestr, datenum

Cite As

Elmar Tarajan (2021). UIGETDATE (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (21)

Luke Bradley

Works on 2021a!


Matthew Schroeder

Excellent work! Tested on R2018a.

Noam Greenboim

One issue that's needed to be fixed is the CLOSEREQ call.
Like Tal Shir recognized before, when UIGETDATE is called within another GUI, closing the window causes the closure of the calling GUI.
to fix that:
replace line 120: closereq
with this: delete(findobj(0,'Tag','uigetdate'))

Remberto Martin

excellent - works on OS X

Juan Pablo Salazar

Gracias, es justo lo que buscaba

per isakson

uigetdate has served well for many years, but now the new version of datenum (R2013b?) issues an error.


% tmp = {'Januar' 'Februar' 'March' 'April' 'May' 'Juni' 'Juli' ...
% 'August' 'September' 'October' 'November' 'December'};
tmp = {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'};


out = datenum([num2str( ...
get(findobj(gcf,'Tag','cday'),'UserData')) '-' ...
get(findobj(gcf,'Tag','months'),'String') '-' ...
get(findobj(gcf,'Tag','year' ),'String') ' ' ...
get(findobj(gcf,'Tag','time' ),'String') ':00'] ...
, 'dd-mmm-yyyy HH:MM:SS' );

I added the format specifier.

Now it seems to work again.


GREAT work!


Amazing !!

Liam Kelly

Great tool. However, it will not compile as a stand alone application with the MCR compiler because of the use of strings as callback functions (e.g. ...'callback','uigetdate(gcbo,''year'')')

Liam Kelly


Hi Elmar! This is the the nicest and coolest GUI built by conventional MATLAB methods I've ever seen. Beside the usability, it is an excellent example for advanced programmers. Thanks!

Deshan Yang

Fantastic. It is exactly what I need.

Vincent De Paul

This is a fantastic DateGUI, as Matlab doesn't have such utilities. It can be easily integrated in any Matlab code, in which a calendar is need.

Great Job

Tal Shir

Sorry for adding the rating twice. a small point is the try catch lines. If the gui is used in a parent gui the closereq command will close the main gui in case the x button was used to close the uigetdate. a solution can be to add the following lines between catch and end:
out = [];
if strcmp(get(gcf,'tag'),'uigetdate') % close only if calander is not close already

Gilles Criton

I have not yet practice a full test in order to see if there are some bugs, but at first glance, this function is very impressive and useful ! Thank you very much

Blaz Daskobler

Indeed a very handy tool, thanks a lot.
But, as a previous user observed, the "closereq" command (line 120 to be precise, not 127) needs to be commented out.
You close the uigetdate figure with the "X" (or Close) anyway, and that's why that "closereq" command closes the figure calling uigetdate.

per isakson

It looks nice and works well. However, I encounter a minor issue. When I click the Close Button in the Title Bar "my" figure is closed together with the uigetdate figure. By stepping through the code with the debugger I see that <line 117 uiwait> closes the uigetdate figure and that <line 127 closereq> closes my figure. Don't ask me why (R2006b)! Commenting out <line 127> seems to solve the issue.

Malcolm Wood

This is really impressive.

Kevin Delaney

Just what I was looking for!

Andreas Geissler

Hello, the M-File works great.
No problems !

MATLAB Release Compatibility
Created with R14SP2
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: PlotMeTheGreeks, uisetdate2(varargin)

Community Treasure Hunt

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

Start Hunting!