Sponsored Content
Top Forums Shell Programming and Scripting calculate the date of next satureday of current date. Post 302231643 by Ygor on Tuesday 2nd of September 2008 11:05:31 PM
Old 09-03-2008
Try this function...
Code:
#!/usr/bin/ksh

function dayshift {
  perl -e '@f = localtime(time+(86400*$ARGV[0]));
    printf "%04d%02d%02d\n", $f[5]+1900, $f[4]+1, $f[3];' -- $1
}

NEXT_MONDAY=$(dayshift $((8-$(date '+%u'))))

...format is YYYYMMDD, but change the printf if you want.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Date One Week Ago From Given Date, Not From Current Date

Hi all, I've used various scripts in the past to work out the date last week from the current date, however I now have a need to work out the date 1 week from a given date. So for example, if I have a date of the 23rd July 2010, I would like a script that can work out that one week back was... (4 Replies)
Discussion started by: Donkey25
4 Replies

2. UNIX for Dummies Questions & Answers

Delete a row from a file if one column containing a date is greater than the current system date

Hello gurus, I am hoping someone can help me with the required code/script to make this work. I have the following file with records starting at line 4: NETW~US60~000000000013220694~002~~IT~USD~2.24~20110201~99991231~01~01~20101104~... (4 Replies)
Discussion started by: chumsky
4 Replies

3. Programming

Calculate the current date.

Give your an integer (e.g. 0x0076f676) representing the number of minutes elapsed since January 1, 1996. How to calculate the current date which format should be "year-month-day-hour-minutes" ? (3 Replies)
Discussion started by: qcmao
3 Replies

4. Shell Programming and Scripting

Fetch date of 7 years back from current date in Perl

$beginDate = substr(DateCalc("today", "-7Days"),0,8); This fetches the date 7 days back Can I fetch the date before 7 years from todays date in Perl using same syntax Use code tags, see PM. (3 Replies)
Discussion started by: parthmittal2007
3 Replies

5. UNIX for Dummies Questions & Answers

Adding hours and minutes to current date (Only to date not to time)

Hi, I want to add some hours and minutes to the current date. For example, if the current date is "July 16, 2012 15:20", i want to add 5 hours 30 minutes to "July 16, 2012 00:00" not to "July 16, 2012 15:20". Please help. Thanks! (4 Replies)
Discussion started by: manojgarg
4 Replies

6. HP-UX

awk command in hp UNIX subtract 30 days automatically from current date without date illegal option

current date command runs well awk -v t="$(date +%Y-%m-%d)" -F "'" '$1 < t' myname.dat subtract 30 days fails awk -v t="$(date --date="-30days" +%Y-%m-%d)" -F "'" '$1 < t' myname.dat awk command in hp unix subtract 30 days automatically from current date without date illegal option error... (20 Replies)
Discussion started by: kmarcus
20 Replies

7. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies

8. Linux

How to calculate the quarter end date according to the current date in shell script?

Hi, My question is how to calculate the quarter end date according to the current date in shell script? (2 Replies)
Discussion started by: Divya_1234
2 Replies

9. UNIX for Beginners Questions & Answers

“sed” replace date in text file with current date

We want to call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ Code: line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to write a... (3 Replies)
Discussion started by: pradeepp
3 Replies

10. UNIX for Beginners Questions & Answers

How to replace a parameter(variable) date value inside a text files daily with current date?

Hello All, we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies
CGI::Untaint::date(3pm) 				User Contributed Perl Documentation				   CGI::Untaint::date(3pm)

NAME
CGI::Untaint::date - validate a date SYNOPSIS
use CGI::Untaint; my $handler = CGI::Untaint->new($q->Vars); my $date = $handler->extract(-as_date => 'date'); DESCRIPTION
is_valid This Input Handler verifies that it is dealing with a reasonable date. Reasonably means anything that Date::Manip thinks is sensible, so you could use any of (for example): "December 12, 2001" "12th December, 2001" "2001-12-12" "next Tuesday" "third Wednesday in March" See Date::Manip for much more information on what date formats are acceptable. The resulting date will be a Date::Simple object. Date::Simple for more information on this. date_format By default ambiguous dates of the format 08/09/2001 will be treated as UK style (i.e. 8th September rather than 9th August) If you want to change this, subclass it and override date_format() WARNING
Date::Manip does not play nicely with taint mode. In order to work around this we locally clobber Date::Manip's 'timezone' code. As we're only interested in dates rather than times, this shouldn't be much of an issue. If it is, then please let me know! SEE ALSO
Date::Simple. Date::Manip. AUTHOR
Tony Bowden BUGS and QUERIES Please direct all correspondence regarding this module to: bug-CGI-Untaint-date@rt.cpan.org COPYRIGHT and LICENSE Copyright (C) 2001-2005 Tony Bowden. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.0 2008-05-12 CGI::Untaint::date(3pm)
All times are GMT -4. The time now is 06:51 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy