Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28602 Discussions

how to add 1 day to a date in a string

Brian_Murphy
New Contributor II
3,598 Views

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
JohnNichols
Valued Contributor III
385 Views

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.

 

0 Kudos
mecej4
Honored Contributor III
385 Views

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, https://www.fourmilab.ch/documents/calendar/ and http://www.epistemeacademy.org/calendars/page_today.html . In many societies, social and religious practices are tied to the local calendar system.

0 Kudos
FortranFan
Honored Contributor III
385 Views

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: https://github.com/fortran-lang/stdlib

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.

0 Kudos
Reply