Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.
27554 Discussions

how to add 1 day to a date in a string

New Contributor II

I have a date in "YYYY-MM-DD HH:mm:ss" format with the 19 characters in an integer array.  Is there an easy way to add one day to this?

0 Kudos
23 Replies
Valued Contributor II

Do not forget that the time and date is not a linear function any longer.  You may need to allow for the leap seconds that are added in from time to time. There is a kernel that supplies this data.


Black Belt

dboggs wrote:

A permanent entry on my wish list for Fortran is a new data type, Dattime (or whatever). 

Unless the desired type is restricted to the scope of the modern Western calendar, the task can become quite complex and beyond the scope of knowledge possessed by a typical programmer. See, for example, and . In many societies, social and religious practices are tied to the local calendar system.

Honored Contributor II

dboggs wrote:

Thanks to all for these contributions.

A permanent entry on my wish list for Fortran is a new data type, Dattime (or whatever). Like some other languages (especially Excel, to use the term loosely) it would handle not only arithmetic, but some functions (e.g. Julian date conversion) and a family of edit descriptors for I/o. Would save lots of people lots of time.

@dboggs and anyone interested in such a date-time facility, this looks like a good feature for a community-developed "standard" library for Fortran.

See this initiative:

You may want to consider participating in this or supporting the community developers in a manner you see fit e.g., sharing your ideas, extending your feedback on the development, etc.