Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
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

Brian_Murphy
New Contributor II
1,210 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 II
85 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.

 

mecej4
Black Belt
85 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.

FortranFan
Honored Contributor II
85 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.

Reply