Shell Scripting Date manipulation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Scripting Date manipulation
# 1  
Old 07-16-2013
Shell Scripting Date manipulation

Hi Experts,

i have date as inputdate=01/01/2013,how to get the previous date from this date and also first day's date of the month.

example:

inputdate=01/06/2013

previousdate=31/05/2013

firstdate=01/05/2013

how can i get solution to this. my unix is not supporting GNU Dates


regrads,

Last edited by Scott; 07-16-2013 at 07:40 AM.. Reason: Another continuation of a previous thread (bump) and no code tags. Closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get the consecutive last 10 week day date using UNIX ksh shell scripting?

Hi, i am writing a ksh shell script to check the last month end date whether it is falling in last 10 week day date, I am not sure How to use "Mr. Perderabo's date calculator", Could you Please let me know how to use to get my requirement, I tried my own script but duplicate week day and... (5 Replies)
Discussion started by: karthikram
5 Replies

2. Shell Programming and Scripting

Stream manipulation in UNIX shell scripting

i have a file something like this : start: 01:00:00 01:30:00 02:30:00 05:30:00 end: 01:13:00 02:00:00 02:40:00 05:45:00 and i want (end - start) total run time in below format: run: 00:13:00 00:30:00 00:10:00 00:15:00 (4 Replies)
Discussion started by: Acme
4 Replies

3. Shell Programming and Scripting

AIX Scripting for File Manipulation

Hi, Totally newbie in scripting. And need helps in preparing a script to help me to do file moving, renaming and even delete. I have 2 directories. 1. /FTP/new 2. /FTP/backup Scenario a) I will be getting new text files (e.g NewFile23052013.txt) created in the directory #1 every day... (1 Reply)
Discussion started by: quickerz
1 Replies

4. Shell Programming and Scripting

Shell Scripting: Copy Files with Today's date

I was wondering the best way about finding files that were created today and copy them to a directory (grep ?). There can be multiple files for todays date or none. I am looking to copy all of the .lis files for todays date. I may need to modify the filename to include todays date but for the... (4 Replies)
Discussion started by: smkremer
4 Replies

5. Shell Programming and Scripting

Date Manipulation

I have a file with a field containing the following: "7/3/2009 7:07:12 PM","xxxx" I need to be able to split this field up into two into a different format with the time being converted into 24 hour: so that i can get the following: "20090307","19:07:12","xxxx" (8 Replies)
Discussion started by: Pablo_beezo
8 Replies

6. Shell Programming and Scripting

Shell scripting string manipulation

Hi, if I have a string delimited by commas how can I put each character on a new line followed by a carriage return, and output this to a filee.g from: s,t,r,i,n,g to s t r i n g thanks you (3 Replies)
Discussion started by: Wahmed9
3 Replies

7. Shell Programming and Scripting

Scripting neophyte needs file manipulation assistance

I need to write two shell scripts for an rsync backup solution. The first script will copy all backed up files into a folder named after the original folder, plus a date stamp (so e.g. if the original folder name is 'foo' and is backed up on the 10th of September, then the backup folder will be... (0 Replies)
Discussion started by: LambdaCalculus
0 Replies

8. Shell Programming and Scripting

date manipulation

HI, I'm comparing my file date with the system date and if both the dates are equal I'm doing some operation. I use two variables for these two dates. I use the following command in my query. if .... But here the current date $cd shows 01 and filedate $fdate shows 1. The file is created on 1 of ... (6 Replies)
Discussion started by: pstanand
6 Replies

9. Shell Programming and Scripting

Manipulation of Date in Shell

Reuirement: I have a set of files ina diectory which has the name in format "WWW-YYYYmmDD" like, WWW-20070226. for 26th FEB 2007. Now I need to write a shell script which should move the files to directory named "old" in the same directory if date attached to file is 90 days prior to today's... (1 Reply)
Discussion started by: jnanesh.b
1 Replies

10. Shell Programming and Scripting

Date format - Shell scripting gurus please help

Guys: I have the following script (from this forum) to calculate yesterdays date. However the format of the date that is output is yyyymd if the resultant date is single digit or the resultant month is a single digit month ( 01 - 09 ). How can I get the output to show the date in the following... (3 Replies)
Discussion started by: geomonap
3 Replies
Login or Register to Ask a Question
DATETIME.MODIFY(3)							 1							DATETIME.MODIFY(3)

DateTime::modify - Alters the timestamp

       Object oriented style

SYNOPSIS
public DateTime DateTime::modify (string $modify) DESCRIPTION
Procedural style DateTime date_modify (DateTime $object, string $modify) Alter the timestamp of a DateTime object by incrementing or decrementing in a format accepted by strtotime(3). PARAMETERS
o $object -Procedural style only: A DateTime object returned by date_create(3). The function modifies this object. o $modify -A date/time string. Valid formats are explained in Date and Time Formats. RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.6 | | | | | | | Absolute date/time statements now take effect. | | | Previously, only relative parts were used. | | | | | 5.3.0 | | | | | | | Changed the return value on success from NULL to | | | DateTime. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 DateTime.modify(3) example Object oriented style <?php $date = new DateTime('2006-12-12'); $date->modify('+1 day'); echo $date->format('Y-m-d'); ?> Procedural style <?php $date = date_create('2006-12-12'); date_modify($date, '+1 day'); echo date_format($date, 'Y-m-d'); ?> The above examples will output: 2006-12-13 Example #2 Beware when adding or subtracting months <?php $date = new DateTime('2000-12-31'); $date->modify('+1 month'); echo $date->format('Y-m-d') . " "; $date->modify('+1 month'); echo $date->format('Y-m-d') . " "; ?> The above example will output: 2001-01-31 2001-03-03 SEE ALSO
strtotime(3), DateTime.add(3), DateTime.sub(3), DateTime.setDate(3), DateTime.setISODate(3), DateTime.setTime(3), DateTime.setTimes- tamp(3). PHP Documentation Group DATETIME.MODIFY(3)