INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to find missing dates?

How to find missing dates?

(OP)
Hello guys, I have a problem, I need find the missing dates of the year, for example this is my input:
2014-11-25T12:00:00
2014-11-26T12:00:00
2014-11-27T12:00:00
2014-11-28T12:00:00
2014-11-29T12:00:00
2014-11-30T12:00:00
2014-11-01T12:00:00
2014-11-02T12:00:00
2014-11-03T12:00:00
2014-11-04T12:00:00
2014-11-05T12:00:00
2014-11-06T12:00:00
2014-11-07T12:00:00
2014-11-08T12:00:00
2014-11-09T12:00:00
2014-11-10T12:00:00
2014-11-11T12:00:00

And the output will be all dates in that format less the dates I have, any ideas?

RE: How to find missing dates?

Hi

The easiest is to load all those data in an array, then loop from January 1st to December 31st and display those not in the array :

CODE --> command-line

gawk 'd[$1]=0;END{t=mktime(year" 01 01 12 00 00");while((s=strftime("%FT%T",t))&&substr(s,1,4)==year){if(!(s in d))print s;t+=60*60*24}}' year=2014 /path/to/input 
The above code works with GNU awk only. You have to specify the year as variable assignment in the command line and specify the input file name too.

Note that you may want to hard code the hour of day as 12 in case your machine's time zone supports daylight saving and you not want the noon at summer to be 13:00:00. ( I mean, just change "%T" to "12:00:00". )

Feherke.
feherke.ga

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close